ASP. NET custom MessageBox script

Source: Internet
Author: User

Public class MessageBox
{
Private MessageBox ()
{

// Response. Write ("<SCRIPT> alert ('failed to add company information! '); </SCRIPT> ");
// Clientscript. registerstartupscript (this. GetType (), "Return", "<SCRIPT> alert ('prompt: Error! '); Window. Location. href = 'infolist. aspx'; </SCRIPT> ");
}

/// <Summary>
/// Display the message prompt dialog box
/// </Summary>
/// <Param name = "page"> current page pointer, which is generally this </param>
/// <Param name = "MSG"> message </param>
Public static void show (system. Web. UI. Page, string MSG)
{
Page. registerstartupscript ("message", "<script language = 'javascript 'defer> alert ('" + msg. tostring () + "'); </SCRIPT> ");
}

/// <Summary>
/// Control click the message confirmation prompt box

/// </Summary>
/// <Param name = "page"> current page pointer, which is generally this </param>
/// <Param name = "MSG"> message </param>
Public static void showconfirm (system. Web. UI. webcontrols. webcontrol control, string MSG)
{
// Control. Attributes. Add ("onclick", "If (! Window. Confirm ('"+ MSG +"') {return false ;}");
Control. Attributes. Add ("onclick", "Return confirm ('" + MSG + "');");
}

/// <Summary>
/// Display the message prompt dialog box and jump to the page

/// </Summary>
/// <Param name = "page"> current page pointer, which is generally this </param>
/// <Param name = "MSG"> message </param>
/// <Param name = "url"> Target URL </param>
Public static void showandredirect (system. Web. UI. Page, string MSG, string URL)
{
Stringbuilder builder = new stringbuilder ();
Builder. append ("<script language = 'javascript 'defer> ");
Builder. appendformat ("alert ('{0}');", MSG );
Builder. appendformat ("Top. Location. href = '{0}'", URL );
Builder. append ("</SCRIPT> ");
Page. registerstartupscript ("message", builder. tostring ());

}
/// <Summary>
/// Output Custom Script Information

/// </Summary>
/// <Param name = "page"> current page pointer, which is generally this </param>
/// <Param name = "script"> output script </param>
Public static void responsescript (system. Web. UI. Page, string script)
{
Page. registerstartupscript ("message", "<script language = 'javascript 'defer>" + script + "</SCRIPT> ");
}
}

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.