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