Response. Write () in Ajax updatepannel

Source: Internet
Author: User
I encountered this problem again today. I searched and sorted it out. There are three ways to solve the problem in the West:

Protected void button#click (Object sender, eventargs E)
{
1. response. Write ("<script language = JavaScript>/r alert (/" modification failed! /");/R </SCRIPT> ");

2. scriptmanager. registerstartupscript (updatepanel1, typeof (updatepanel), "alert", "alert ('Hello! '); ", True );
3. Page. registerstartupscript ("alert", "<script language = 'javascript '> window. showmodelessdialog (/" javascript: Alert ('Hello! ');/",/"/",/" Status: No; resizable: No; help: No; dialogheight: Height: 30px; dialogheight: 40px ;/") </SCRIPT> ");
4. // clientscript. registerclientscriptblock (typeof (updatepanel), "alert", "<SCRIPT> alert ('Do it yourself! ') </SCRIPT> ", true );
}

Front-end Page code;

<Form ID = "form1" runat = "server">
<Div>
<Div>
<Asp: scriptmanager id = "scriptmanager1" runat = "server">
</ASP: scriptmanager>

</Div>
<Asp: updatepanel id = "updatepanel1" runat = "server">
<Triggers>
<Asp: postbacktrigger controlid = "button1"/>
</Triggers>
<Contenttemplate>
<Asp: button id = "button1" runat = "server" text = "button" onclick = "button#click"> </ASP: button>
</Contenttemplate>
</ASP: updatepanel>

</Div>
</Form>

<Triggers>
<Asp: postbacktrigger controlid = "button1"/>
</Triggers>

You do not need to add the following types.

However, I have observed that the first type is Refresh, and the second and third types are not flushed. The fourth type does not seem to be able to respond, but the Internet says yes, I don't know...

Related Article

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.