asp.net the solution for registering scripts in Updatepnael in Ajax beta

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.