Asp.net (C #) Warning operation class

Source: Internet
Author: User

The following class is found on the network because it often involves writing JS pop-up warning dialog boxes when writing background programs:

/####################################### #####
Copyright:
The content of this article is edited on this site. You can reprint, publish, and use it as needed. However, please note the original source and this statement in plain text.
Http://www.opent.cnAuthor: langtaosha
######################################## ####/

Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. text;

Namespace EC
{
/// <Summary>
/// General information output method
/// </Summary>
Public class messageobject
{

/// <Summary>
/// General output
/// </Summary>
/// <Param name = "str"> </param>
Public static void write (string Str)
{
System. Web. httpcontext. Current. response. Write (STR );
}
/// <Summary>
/// Display a custom output code
/// </Summary>
/// <Param name = "mypage"> </param>
/// <Param name = "strcode"> </param>
Public static void showjs (system. Web. UI. Page mypage, string strcode)
{
Stringbuilder sb = new stringbuilder ();
SB. append ("<script language =/" javascript/">/N ");
SB. append (strcode. Trim ());
SB. append ("</SCRIPT> ");
Mypage. response. Write (sb. tostring ());
}
/// <Summary>
/// Page reload
/// </Summary>
Public static void location ()
{
Stringbuilder sb = new stringbuilder ();
SB. append ("<script language =/" javascript/">/N ");
SB. append ("window. Location. href = Window. Location. href ;");
SB. append ("</SCRIPT> ");
System. Web. httpcontext. Current. response. Write (sb. tostring ());

}
/// <Summary>
/// Display a pop-up window
/// </Summary>
/// <Param name = "str"> </param>
Public static void show (string Str)
{
Stringbuilder sb = new stringbuilder ();
SB. append ("<script language =/" javascript/">/N ");
SB. append ("alert (/" "+ Str. Trim () +"/");/N ");
SB. append ("</SCRIPT> ");

System. Web. httpcontext. Current. response. Write (sb. tostring ());
}
/// <Summary>
/// Display a pop-up window and close the current page
/// </Summary>
/// <Param name = "str"> </param>
Public static void showclose (string Str)
{
System. Text. stringbuilder sb = new system. Text. stringbuilder ();
SB. append ("<script language =/" javascript/">/N ");
SB. append ("alert (/" "+ Str. Trim () +"/");/N ");
SB. append ("window. Close ();/N ");
SB. append ("</SCRIPT>/N ");
System. Web. httpcontext. Current. response. Write (sb. tostring ());
}
/// <Summary>
/// Display a pop-up window and switch to the current page (refresh)
/// </Summary>
/// <Param name = "str"> </param>
Public static void showlocation (string Str)
{
Stringbuilder sb = new stringbuilder ();
SB. append ("<script language =/" javascript/">/N ");
SB. append ("alert (/" "+ Str. Trim () +"/");/N ");
SB. append ("window. Location. href = Window. Location. href;/N ");
SB. append ("</SCRIPT> ");

System. Web. httpcontext. Current. response. Write (sb. tostring ());
}
/// <Summary>
/// Display a pop-up window and navigate to the target page (navigation)
/// </Summary>
/// <Param name = "str"> </param>
/// <Param name = "url"> </param>
Public static void showredirect (string STR, string URL)
{
Stringbuilder sb = new stringbuilder ();
SB. append ("<script language =/" javascript/">/N ");
SB. append ("alert (/" "+ Str. Trim () +"/");/N ");
SB. append ("window. Location. href =/" "+ URL. Trim () +"/";/N ");
SB. append ("</SCRIPT> ");

System. Web. httpcontext. Current. response. Write (sb. tostring ());
}
/// <Summary>
/// Display a pop-up window and move to the previous page
/// </Summary>
/// <Param name = "str"> </param>
Public static void showpre (string Str)
{
Stringbuilder sb = new stringbuilder ();
SB. append ("<script language =/" javascript/">/N ");
SB. append ("alert (/" "+ Str. Trim () +"/");/N ");
SB. append ("Var P = Document. referrer;/N ");
SB. append ("window. Location. href = P;/N ");
SB. append ("</SCRIPT> ");

System. Web. httpcontext. Current. response. Write (sb. tostring ());
}
/// <Summary>
/// Redirect
/// </Summary>
/// <Param name = "url"> </param>
Public static void redirectpage (string URL)
{
String Path = "http: //" + system. Web. httpcontext. Current. Request. url. Host + URL;
Stringbuilder sb = new stringbuilder ();
SB. append ("<script language =/" javascript/">/N ");
SB. append (string. Format ("window. Location. href = '{0}';", @ path ));
SB. append ("</SCRIPT> ");

System. Web. httpcontext. Current. response. Write (sb. tostring ());
}


}
}

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.