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