Solve the problem that UpdatePanel cannot directly export the window

Source: Internet
Author: User
/// <Summary>
/// Customize the pop-up window content
/// </Summary>
/// <Param name = "msg"> </param>
Public static void AjaxShowWindows (string msg)
{
// MyContext. Response. Write ("<script> export the window generation parameters (wondows. open (XXX); </script> ");
String script = "generate window generation parameters (wondows. open (XXX);"; // note the window ID. It is best to use a host. Otherwise, only one output is allowed.
ScriptManager. RegisterStartupScript (System. Web. UI. Page) HttpContext. Current. CurrentHandler, typeof (System. Web. UI. Page), "ShowWindows", script, true );
}

=

Using System;
Using System. Collections. Generic;
Using System. Text;

Using System. Web;
Using System. Web. UI;

Public class ShowMessage
{
/// <Summary>
/// Customize the content of the pop-up window. Do not jump
/// </Summary>
/// <Param name = "page"> </param>
/// <Param name = "msg"> </param>
Public static void Show (System. Web. UI. Page page, string msg)
{
Page. ClientScript. RegisterStartupScript (page. GetType (), "ShowMessage", "alert ('" + msg + "');", true );
}
/// <Summary>
/// Customize the pop-up window content and jump
/// </Summary>
/// <Param name = "page"> </param>
/// <Param name = "msg"> </param>
/// <Param name = "returnUrl"> </param>
Public static void Show (System. Web. UI. Page page, string msg, string returnUrl)
{
Page. clientScript. registerStartupScript (page. getType (), "ShowMessage", "alert ('" + msg + "'); window. location. href = '"+ returnUrl +"'; ", true );
}
/// <Summary>
/// Customize the pop-up window content and jump
/// </Summary>
/// <Param name = "page"> </param>
/// <Param name = "msg"> </param>
/// <Param name = "returnUrl"> </param>
Public static void Show (System. Web. UI. Page page, string msg, string trueReturnUrl, string falseReturnUrl)
{
Page. clientScript. registerStartupScript (page. getType (), "ShowMessage", "if (confirm ('" + msg + "') {javascript: location = '" + trueReturnUrl + "';} else {javascript: location = '"+ falseReturnUrl +"';} ", true );
}

/// <Summary>
/// Customize the pop-up window content
/// </Summary>
/// <Param name = "msg"> </param>
Public static void AjaxShow (string msg)
{
// MyContext. Response. Write ("<script> alert ('" + msg + "'); </script> ");
ScriptManager. registerStartupScript (System. web. UI. page) HttpContext. current. currentHandler, typeof (System. web. UI. page), "ShowMessage", "alert ('" + msg + "');", true );
}
/// <Summary>
/// Customize the pop-up window content and direct it to a new page
/// </Summary>
/// <Param name = "msg"> </param>
/// <Param name = "url"> </param>
Public static void AjaxShow (string msg, string url)
{
// MyContext. response. write ("<script> alert ('" + msg + "'); javascript: location = '" + Url + "'; </script> ");
ScriptManager. registerStartupScript (System. web. UI. page) HttpContext. current. currentHandler, typeof (System. web. UI. page), "ShowMessage", "alert ('" + msg + "'); javascript: location = '" + url + "';", true );

}
/// <Summary>
/// Customize the pop-up window content and choose whether to direct or prompt to switch to a new page
/// </Summary>
/// <Param name = "msg"> </param>
/// <Param name = "isreturn"> </param>
/// <Param name = "url"> </param>
Public static void AjaxShow (string msg, bool isreturn, string url)
{
If (! Isreturn)
{
// MyContext. response. write ("<script> alert ('" + msg + "'); javascript: location = '" + Url + "'; </script> ");
ScriptManager. registerStartupScript (System. web. UI. page) HttpContext. current. currentHandler, typeof (System. web. UI. page), "ShowMessage", "alert ('" + msg + "'); javascript: location = '" + url + "';", true );
}
Else
{
// MyContext. response. write ("<script> alert ('" + msg + "'); javascript: location = '" + Url + "'; </script> ");
ScriptManager. registerStartupScript (System. web. UI. page) HttpContext. current. currentHandler, typeof (System. web. UI. page), "ShowMessage", "if (confirm ('" + msg + "') {javascript: location = '" + url + "';}", true );
}

}
/// <Summary>
/// Customize the pop-up window content to determine whether to close the current page
/// </Summary>
/// <Param name = "msg"> </param>
/// <Param name = "close"> </param>
Public static void AjaxShow (string msg, bool close)
{
If (close)
{
// MyContext. Response. Write ("<script> alert ('" + msg + "'); javascript: window. close (); </script> ");
ScriptManager. registerStartupScript (System. web. UI. page) HttpContext. current. currentHandler, typeof (System. web. UI. page), "ShowMessage", "alert ('" + msg + "'); javascript: window. close (); ", true );
}
Else
{
// MyContext. Response. Write ("<script> alert ('" + msg + "'); </script> ");
ScriptManager. registerStartupScript (System. web. UI. page) HttpContext. current. currentHandler, typeof (System. web. UI. page), "ShowMessage", "alert ('" + msg + "');", true );
}
}
}

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.