JS popup message, and jump to specify page code share

Source: Internet
Author: User

Using System.Web;

<summary>
Client Script output
</summary>
public class Jshelper
{
<summary>
Pop-up information and jump to the specified page.
</summary>
public static void Alertandredirect (String message, String tourl)
{
String js = "<script language=javascript>alert (' {0} '); Window.location.replace (' {1} ') </script>";
HttpContext.Current.Response.Write (String. Format (JS, message, tourl));
HttpContext.Current.Response.End ();
}

<summary>
Pop-up information and return to the history page
</summary>
public static void Alertandgohistory (string message, int value)
{
String js = @ "<script language= ' JavaScript ' >alert (' {0} '); History.go ({1});</script>";
HttpContext.Current.Response.Write (String. Format (JS, message, value));
HttpContext.Current.Response.End ();
}

<summary>
Jump directly to the specified page
</summary>
public static void Redirect (String tourl)
{
String js = @ "<script language=javascript>window.location.replace (' {0} ') </script>";
HttpContext.Current.Response.Write (String. Format (JS, tourl));
}

<summary>
Pop-up information and assign to parent window
</summary>
public static void Alertandparenturl (String message, String tourl)
{
String js = "<script language=javascript>alert (' {0} '); Window.top.location.replace (' {1} ') </script>";
HttpContext.Current.Response.Write (String. Format (JS, message, tourl));
}

<summary>
Return to parent window
</summary>
public static void Parentredirect (String tourl)
{
String js = "<script language=javascript>window.top.location.replace (' {0} ') </script>";
HttpContext.Current.Response.Write (String. Format (JS, tourl));
}

<summary>
Back to History page
</summary>
public static void Backhistory (int value)
{
String js = @ "<script language= ' JavaScript ' >history.go ({0});</script>";
HttpContext.Current.Response.Write (String. Format (JS, value));
HttpContext.Current.Response.End ();
}

<summary>
Popup Information
</summary>
public static void Alert (String message)
{
String js = "<script language=javascript>alert (' {0} ');</script>";
HttpContext.Current.Response.Write (String. Format (JS, message));
}

<summary>
Registering script blocks
</summary>
public static void Registerscriptblock (System.Web.UI.Page Page, String _scriptstring)
{
Page. Clientscript.registerstartupscript (page. GetType (), "Scriptblock", "<script type= ' Text/javascript ' >" + _scriptstring + "</script>");
}
}

JS popup message, and jump to specify page code share

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.