Common pop-up window types

Source: Internet
Author: User

Public class alert
{

# Region warning function
/// <Summary>
/// Write warning. Only the dialog box is displayed.
/// </Summary>
Public static void MessageBox (string text) // the pop-up dialog box is displayed.
{
Httpcontext. Current. response. Write ("<script language = JavaScript> alert ('" + TEXT + "'); </SCRIPT> ");
}
/// <Summary>
/// Write warning. Only the dialog box is displayed to close the window.
/// </Summary>
Public static void messageboxclose (string text) // the pop-up dialog box appears.
{
Httpcontext. Current. response. Write ("<script language = JavaScript> ");
Httpcontext. Current. response. Write ("alert ('" + TEXT + "');");
Httpcontext. Current. response. Write ("window. Close ()");
Httpcontext. Current. response. Write ("</SCRIPT> ");
}

/// <Summary>
/// Write warning, return to the original page
/// </Summary>
Public static void messageboxback (string text) // return to the original page
{
Httpcontext. Current. response. Write ("<script language = JavaScript> ");
Httpcontext. Current. response. Write ("alert ('" + TEXT + "');");
Httpcontext. Current. response. Write ("window. History. Go (-1 )");
Httpcontext. Current. response. Write ("</SCRIPT> ");
}
/// <Summary>
/// Page redirection
/// Text warning text, turning to page, turning to target
/// </Summary>
Public static void messageboxredirect (string text, string gourl, string target)
{
If (target = "" | target = NULL)
{Target = "window ";}
Httpcontext. Current. response. Write ("<script language = JavaScript> ");
Httpcontext. Current. response. Write ("alert ('" + TEXT + "');");
Httpcontext. Current. response. Write ("window." + target + ". Location = '" + gourl + "';");
Httpcontext. Current. response. Write ("</SCRIPT> ");
}
/// <Summary>
/// Page redirection
/// Text warning text, turning to page
/// </Summary>
Public static void messageboxredirect (string text, string gourl)
{
Httpcontext. Current. response. Write ("<script language = JavaScript> ");
Httpcontext. Current. response. Write ("alert ('" + TEXT + "');");
Httpcontext. Current. response. Write ("window. Location = '" + gourl + "';");
Httpcontext. Current. response. Write ("</SCRIPT> ");
}
# Endregion

/// <Summary>
/// Handle dangerous code entered by the user
/// </Summary>
/// Define the inputtext function for Input
Public static string inputtext (string inputstring, int maxlength)
{
Stringbuilder retval = new stringbuilder (); // construct a temporary String Array
If (inputstring! = NULL) & (inputstring! = String. Empty ))
{
Inputstring = inputstring. Trim (); // clear the blank characters of the two segments of the string.
If (inputstring. length> maxlength)
{// Set the string length
Inputstring = inputstring. substring (0, maxlength );
}
For (INT I = 0; I <inputstring. length; I ++)
{
Switch (inputstring [I])
{
/// Remove dangerous strings (\,/,:,*,?, ", <,>, |)
Case '*':
Case '| ':
Case '<':
Case '> ':
Case '/':
Case '\\':
Case ':':
Case '? ':
Case '"':
Retval. append (""); break;
Default: retval. append (inputstring [I]); break;
}
}
Retval. Replace ("'","");
}
Return retval. tostring ();
}

/// <Summary>
/// Dynamically load the drop-down menu
/// </Summary>
Public static void addlistitem (listcontrol control, string value, string text)
{
Listitem item = new listitem ();
Item. Text = text;
Item. value = value;
Control. Items. Add (item );
}

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.