为控件增加客户端属性的三种方法


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

?a.直接向控件添加客户端属性
<asp:Button ID=”MyButton” Text=”ClickMe” onmouseover=”this.style.cursor=’pointer'” runat=”server” />

b.调用内置方法
可以通过调用WebControl.Attributes.Add()方法为控件添加客户端属性,如下所示:

MyButton.Attributes.Add(“onmouseover”, “this.style.cursor=’pointer'”);

c. OnClientClick
MyButton.OnClientClick = “alert(‘Hello!’)”;