Recently also looked at some asp.net ajax data, on the Internet to see a lot of people are asking how to register the script in the UpdatePanel, I also tried, but always do not, just read a lot of information, finally know that they do not fully understand Scriptmanager.registerclientscriptblock (Control Control,type type,string Key, String Script,bool addscripttags), Each of these parameters. (Note: RegisterClientScriptBlock is a static method of ScriptManager)
Parameter detailed:
CONTROLS: This parameter is a control that registers a script block. If you are registering in UpdatePanel, that is UpdatePanel (should write UpdatePanel ID).
Type: This parameter is the type of the registry script block control, that is, the UpdatePanel type.
Key (String): This parameter is the unique identifier for the script cool block (keyword)
Script (String): This parameter is the script string to register.
addScriptTags (Boolean): This parameter indicates whether you want to surround yourself with "<script>" and "</script>" on both sides of your string.
And then this is a simple example of what I wrote:
HTML code:
<title>untitled page</title>
<link http://www.knowsky.com/article.asp?typeid=38 ">css/default.css"
Rel= "stylesheet" type= "Text/css"/>
<body>
<form id= "Form1" runat= "Server" >
<asp:scriptmanager id= "ScriptManager1" runat= "Server"/>
<asp:updatepanel id= "UpdatePanel1" runat= "Server" >
<ContentTemplate>
<asp:button id= "Button1" runat= "Server" onclick= "Button1_Click" text= "button"/>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
CS Code:
protected void Button1_Click (object sender, EventArgs e)
{
Scriptmanager.registerclientscriptblock (UpdatePanel1, typeof (UpdatePanel), "Test", "alert (' Test ');", true);
}
The above is my understanding, if there is not the correct place, please correct, I first put to the home page, in fact, there is no technical content, mainly used to let those who do not know how to register friends see. After that, Dohu can be deleted.
Http://www.cnblogs.com/sunlife/archive/2006/11/05/550520.html