(1)动态改变<asp:Button>外观 <asp:Button id="Button1"οnmοuseοut="this.style.backgroundColor='blue'" οnmοuseοver="this.style.backgroundColor='red'" runat="server" />
(2)脚本检验数据 一、在页面中写上javascript的函数: <script language=javascript> function test(){ alert("this is test!!"); } function test2(){ var state = confirm("是否删除?"); return state; }
</scirpt> 二、在后置文件中的Page_Load()事件中邦定控件 Button1.Attributes.Add("onclick","javascript:return test();"); 三、让<ASP:TextBox …… /> 获得焦点 1.document.getElementById("myTextBox").focus(); 2.document.myForm1.myTextBox.focus(); 四、Page.RegisterStartupScript(key,script) 允许ASP.NET服务器控件在System.Web.UI.Page中发出客户脚本块。 key是运行时脚本的一个文本索引;script表示客户端脚本的正文文本。 string str="<scr"+"ipt> alert('"+parReason.Value.ToString() + "');</scr"+"ipt>"; this.RegisterStartupScript("reason",str);