Js
Using System;
Using System.Web;
Using System.Web.UI;
Using System;
Using System.Web;
Using System.Web.UI;
Namespace 4ec{
<summary>
Some common JS calls
</summary>
public class Jscript
{
<summary>
Pop-up JavaScript small window
</summary>
<param name= "JS" > Window information </param>
public static void Alert (String message)
{
#region
String js = @ "<script language= ' JavaScript ' >
Alert (' "+ Message +" ');</script> ";
HttpContext.Current.Response.Write (JS);
#endregion
}
<summary>
Pop-up message box and move to the new URL
</summary>
<param name= "message" > Content </param>
<param name= "Tourl" > Connection address </param>
public static void Alertandredirect (String message, String tourl)
{
#region
String js = "<script language=javascript>alert (' {0} '); Window.location.replace (' {1} ') </script>";
HttpContext.Current.Response.Write (String. Format (JS, message, tourl));
#endregion
}
<summary>
Back to History page
</summary>
<param name= "Value" >-1/1</param>
public static void Gohistory (int value)
{
#region
String js = @ "<script language= ' JavaScript ' >
History.go ({0});
</Script> ";
HttpContext.Current.Response.Write (String. Format (JS, value));
#endregion
}
<summary>
Close the current window
</summary>
public static void CloseWindow ()
{
#region
String js = @ "<script language= ' JavaScript ' >
Parent.opener=null;window.close ();
</Script> ";
HttpContext.Current.Response.Write (JS);
HttpContext.Current.Response.End ();
#endregion
}
<summary>
Refreshing the parent window
</summary>
public static void Refreshparent (string url)
{
#region
String js = @ "<script>try{top.location=" "+url+@" ""}catch (e) {location= "" +url+@ ""}</script> ";
HttpContext.Current.Response.Write (JS);
#endregion
}
<summary>
Refresh Open Window
</summary>
public static void Refreshopener ()
{
#region
String js = @ "<script language= ' JavaScript ' >
Opener.location.reload ();
</Script> ";
HttpContext.Current.Response.Write (JS);
#endregion
}
<summary>
Opens a new form of the specified size
</summary>
<param name= "url" > Address </param>
<param name= "width" > Width </param>
<param name= "Heigth" > High </param>
<param name= "Top" > Head position </param>
<param name= "left" > Position </param>
public static void Openwebformsize (string url, int width,int heigth,int Top,int left)
{
#region
String js = @ "<script language= ' JavaScript ' >window.open (' + URL + @" ', ', ' height= ' + heigth + ", width=" + width + ") , top= "+top+", left= "+left+", location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar= No,directories=no ');</script> ";
HttpContext.Current.Response.Write (JS);
#endregion
}
<summary>
Turn to URL-made page
</summary>
<param name= "url" > Connection address </param>
public static void Javascriptlocationhref (string url)
{
#region
String js = @ "<script language= ' JavaScript ' >
Window.location.replace (' {0} ');
</Script> ";
JS = string. Format (JS, url);
HttpContext.Current.Response.Write (JS);
#endregion
}
<summary>
Opens a modal dialog box with a specified size position
</summary>
<param name= "Webformurl" > Connection address </param>
<param name= "width" > Width </param>
<param name= "height" > High </param>
<param name= "Top" > Distance position </param>
<param name= "left" > Away position </param>
public static void Showmodaldialogwindow (string webformurl, int width, int. height, int top, int left)
{
#region
String features = "Dialogwidth:" + width. ToString () + "px"
+ ";d ialogheight:" + height. ToString () + "px"
+ ";d ialogleft:" + left. ToString () + "px"
+ ";d ialogtop:" + top. ToString () + "px"
+ "; Center:yes;help=no;resizable:no;status:no;scroll=yes";
Showmodaldialogwindow (Webformurl, features);
#endregion
}
public static void Showmodaldialogwindow (String webformurl, String Features)
{
string js = Showmodaldialogjavascript (Webformurl, features);
HttpContext.Current.Response.Write (JS);
}
public static string Showmodaldialogjavascript (string Webformurl, String features)
{
#region
String js = @ "<script language=javascript>
ShowModalDialog (' + Webformurl + "', ', '" + features + ');</script> ";
Return JS;
#endregion
}
}
}