ASP.net pop-up dialog box base class (Output Alet warning box) _ Practical Tips

Source: Internet
Author: User
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 method of information output
</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>
Show 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 overload
</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>
Displays a pop-up window and closes 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>
Displays a pop-up window and turns 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>
Displays a pop-up window and moves 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>
Displays a pop-up window and moves 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.