ASP.NET 1.x:
btnTest.Attributes.Add( "onclick", "javascript:this.disabled = true; " + GetPostBackEventReference( btnTest ) );
ASP.NET 2.0:
btnTest.Attributes.Add( "onclick", string.Format( "javascript:this.disabled = true; {0}", ClientScript.GetPostBackEventReference( btnTest, "" ) ) );
Advantages:
- You only need a handle to the control instead of the ID - sometimes these can get complicated if controls are placed inside other controls
- There is less code
- Only a single control is ouputted - this could mean a performance increase compared to using Ghost Buttons
- The code will need to be recompiled to make any changes to the click event
No comments:
Post a Comment