Monday, October 29, 2007

Ajax UpdatePanel (11) ScriptManager 1

Asp.net register script functions:


<form id="form1" runat="server">

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

</form>



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>");

}

blog comments powered by Disqus