您的位置:首页 > Web前端 > JavaScript

从服务器端向页面中发送javascript代码

2007-04-28 17:23 232 查看
protected void Button1_Click(object sender, EventArgs e)
{
ClientScriptManager cs = this.ClientScript;
cs.RegisterArrayDeclaration("Hello", "1, 2, 3");
cs.RegisterClientScriptBlock(this.GetType(), "HelloWorld", "function helloWorld(){alert(1);}", true);
cs.RegisterClientScriptInclude("HelloWorld", "HelloWorld.js");
// cs.RegisterClientScriptResource(
cs.RegisterExpandoAttribute(this.Button1.ClientID, "Hello", "World");
cs.RegisterHiddenField("hello", "world");
cs.RegisterOnSubmitStatement(this.GetType(), "HelloWorld", "return window.confirm('Do you really want to submit the form?')");
cs.RegisterStartupScript(this.GetType(), "HelloWorld", "<script>alert('The page has loaded!')</script>");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: