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> ");
}
}