从 ASP.NET 服务器控件插入客户端脚本
2005-03-16 23:07
489 查看
http://www.microsoft.com/china/MSDN/library/archives/library/DNAspp/html/aspnet-injectclientsidesc.asp
(1)动态改变<asp:Button>外观
<asp:Button id="Button1"onmouseout="this.style.backgroundColor='blue'" onmouseover="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);
(1)动态改变<asp:Button>外观
<asp:Button id="Button1"onmouseout="this.style.backgroundColor='blue'" onmouseover="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);
相关文章推荐
- 从 ASP.NET 服务器控件插入客户端脚本
- ASP.NET 服务器控件中插入客户端脚本(自定义控件)
- 虽然平时也都经常用到,.net+客户端脚本,从 ASP.NET 服务器控件插入客户端脚本
- 从 ASP.NET 服务器控件插入客户端脚本
- 从 ASP.NET 服务器控件插入客户端脚本(转自MSDN)
- 从 ASP.NET 服务器控件插入客户端脚本
- 从 ASP.NET 服务器控件插入客户端脚本
- 从 ASP.NET 服务器控件插入客户端脚本
- 从 ASP.NET 服务器控件插入客户端脚本
- [转贴]从 ASP.NET 服务器控件插入客户端脚本
- 从 ASP.NET 服务器控件插入客户端脚本(引自MSDN中文网
- 从 ASP.NET 服务器控件插入客户端脚本(引自MSDN中文网站)
- 从 ASP.NET 服务器控件插入客户端脚本
- 从 ASP.NET 服务器控件插入客户端脚本
- 从 ASP.NET 服务器控件插入客户端脚本
- 从 ASP.NET 服务器控件插入客户端脚本
- 绝对酷,如何解决asp.net中javascript脚本的问题(使用服务器控件执行客户端脚本)
- 用一个例子讲述如何向ASP.NET Web服务器按钮控件添加客户端脚本
- 向 ASP.NET Web 服务器控件添加客户端脚本事件
- 向 ASP.NET Web 服务器控件添加客户端脚本事件