JavaScript Action Class

Source: Internet
Author: User
Tags httpcontext

JS Operation class

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;

<summary>
Calling JavaScript scripts
</summary>
public class JScript:System.Web.UI.Page
{
Public JScript ()
{
//
TODO: Add constructor logic here
//
}
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));
}
<summary>
Pop-up JavaScript small window
</summary>
<param name= "JS" > Window information </param>
public static void Alert (String message)
{
Message = Stringutil.deleteunvisiblechar (message);
String js = @ "<script language= ' JavaScript ' >
Alert (' "+ Message +" ');</script> ";
HttpContext.Current.Response.Write (JS);
}
public static void Alert (String strmessage)
//{
Page.registerstartupscript ("", "<script>alert" (' +strmessage+ ");</script>");
String js = @ "<script language= ' JavaScript ' >alert (' +strmessage+ ');</script>";
HttpContext.Current.Response.Write (JS);

//}
public static void Alert (Object message)
{
String js = @ "<script language= ' JavaScript ' >
Alert (' {0} ');
</Script> ";
HttpContext.Current.Response.Write (String. Format (JS, message. ToString ()));
}

public static void Rtnrltmsgbox (Object message, String Strwinctrl)
{
String js = @ "<script language= ' JavaScript ' >
Strwinctrl = true;
Strwinctrl = if (!confirm (' + message + ')] return false;</script> ";
HttpContext.Current.Response.Write (String. Format (JS, message. ToString ()));
}
<summary>
dialog box with ' OK '/' Cancel ' button
</summary>
<param name= The text information of the "StrText" > Dialog box </param>
<param name= "strURL" > redirected address </param>
public static void Messageboxyesno (String strText, String strurl)
{
HttpContext.Current.Response.Write ("<script language= ' JavaScript ' >var ans;");
HttpContext.Current.Response.Write ("ans=window.confirm (' + StrText + ');");
HttpContext.Current.Response.Write ("if (ans==true) {window.location= '" + strURL + "';} </script> ");
HttpContext.Current.Response.Write ("</script>");

}
<summary>
Back to History page
</summary>
<param name= "Value" >-1/1</param>
public static void Gohistory (int value)
{
String js = @ "<script language= ' JavaScript ' >
History.go ({0});
</Script> ";
HttpContext.Current.Response.Write (String. Format (JS, value));
}

   ///<summary>
   ///closes the current window
   ///</summary
    public static void CloseWindow ()
    {
         string js = @ "<script language= ' JavaScript"
                     window.close (); 
                   </Script> ";
        HttpContext.Current.Response.Write (JS);
        HttpContext.Current.Response.End ();
   }

   ///<summary>
   ///Refresh parent window
   ///</summary>
    public static void Refreshparent ()
    {
         string js = @ "<script language= ' JavaScript"
                     parent.location.reload ();
                  < /script> ";
        HttpContext.Current.Response.Write (JS);
   }
   ///<summary>
   ///open window
   ///</summary>
   ///<param name= "url" ></PARAM>
    public static void Openwebform (string url)
    {

/*......................................................................................................*/
/* Start * *
String js = @ "<script language= ' JavaScript ' >
window.open (' "+ URL + @");
window.open (' "+ URL + @" ', ', ', ' Height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes, Status=yes,titlebar=no,toolbar=no,directories=no ');
</Script> ";
/* END * *
/*......................................................................................................*/


HttpContext.Current.Response.Write (JS);
}
public static void Openwebform (string url, string formName)
{
/*......................................................................................................*/
* Modified Personnel: SXS * *
/* Modified time: 2003-4-9/*
/* Modification Purpose: New open page to remove IE menu ... */
/* Comment Content: * *
/* Start * *
String js = @ "<script language= ' JavaScript ' >
window.open (' "+ URL + @" ', ' "+ FormName + @");
window.open (' "+ URL + @" ', ' "+ formName + @" ', ' Height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes, Scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no ');
</Script> ";
/* END * *
/*......................................................................................................*/

HttpContext.Current.Response.Write (JS);
}
</summary>
<param name= "url" >web window </param>
<param name= "IsFullScreen" > Full screen </param>
public static void Openwebform (string URL, bool isfullscreen)
{
String js = @ "<script language= ' JavaScript ' >";
if (IsFullScreen)
{
JS + + "var iwidth = 0;";
JS + + "var iheight = 0;";
JS + + "IWIDTH=WINDOW.SCREEN.AVAILWIDTH-10;";
JS + + "IHEIGHT=WINDOW.SCREEN.AVAILHEIGHT-50;";
JS + + "var szfeatures = ' width= ' + iwidth + ', height= ' + iheight + ', Top=0,left=0,location=no,menubar=no,resizable=yes,scro Llbars=yes,status=yes,titlebar=no,toolbar=no,directories=no '; ';
JS + + "window.open ('" + URL + @ "', ', szfeatures);";
}
Else
{
JS + + window.open (' "+ URL + @" ', ', ' height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars= Yes,status=yes,titlebar=no,toolbar=no,directories=no '); ";
}
JS + + "</Script>";
HttpContext.Current.Response.Write (JS);
}
<summary>
Turn to URL-made page
</summary>
<param name= "url" ></param>
public static void Javascriptlocationhref (string url)
{
String js = @ "<script language= ' JavaScript ' >
Window.location.replace (' {0} ');
</Script> ";
JS = string. Format (JS, url);
HttpContext.Current.Response.Write (JS);
}
</summary>
<param name= "Parentwindowurl" > Parent window </param>
public static void Gotoparentwindow (String parentwindowurl)
{
String js = @ "<script language= ' JavaScript ' >
This.parent.location.replace (' "+ Parentwindowurl +" ');</script> ";
HttpContext.Current.Response.Write (JS);
}
<summary>
Function Name: Showmodaldialogjavascript
Function Description: Returns the script for the Open mode window
Processing process:
Algorithm Description:
Author: Sun Hongbiao
Date: 2003-04-30 15:00
Modify
Date
Version
</summary>
<param name= "Webformurl" ></param>
<returns></returns>
public static string Showmodaldialogjavascript (String webformurl)
{
String js = @ "<script language=javascript>
var iwidth = 0;
var iheight = 0;
iwidth=window.screen.availwidth-10;
iheight=window.screen.availheight-50;
var szfeatures = ' dialogwidth: ' +iwidth+ ';d ialogheight: ' +iheight+ ';d ialogleft:0px;dialogtop:0px;center:yes;help=no ; Resizable:on;status:on;scroll=yes ';
ShowModalDialog (' + Webformurl + "', ', szfeatures);</script>";
Return JS;
}

public static string Showmodaldialogjavascript (string Webformurl, String features)
{
String js = @ "<script language=javascript>
ShowModalDialog (' + Webformurl + "', ', '" + features + ');</script> ";
Return JS;
}
<summary>
Function Name: Showmodaldialogwindow
Function Description: Open mode window
Processing process:
Algorithm Description:
Author: Sun Hongbiao
Date: 2003-04-30 15:00
Modify
Date
Version
</summary>
<param name= "Webformurl" ></param>
<returns></returns>
public static void Showmodaldialogwindow (String webformurl)
{
String js = Showmodaldialogjavascript (Webformurl);
HttpContext.Current.Response.Write (JS);
}

public static void Showmodaldialogwindow (string Webformurl, String features)
{
String js = Showmodaldialogjavascript (Webformurl, features);
HttpContext.Current.Response.Write (JS);
}
public static void Showmodaldialogwindow (string webformurl, int width, int. height, int top, int left)
{
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=no";
Showmodaldialogwindow (Webformurl, features);
}
}

Related Article

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.