asp.net background How to output JS script to use what method can be implemented

Source: Internet
Author: User
Tags httpcontext

 asp.net background How to output the JS script, implemented in Page.ClientScript.RegisterStartupScript mode, implementation, such as below, interested friends don't miss

With page. Clientscript.registerstartupscript Mode implementation     code for:  code as follows:/**////<summary> /// Pop-up JavaScript small window  ///</summary> ///<param name= "JS" > Window information </param>  public static void Alert (String message, page page)   {  #region   String js = @ "<script language= ' JavaScript ' >&nbsp ; Alert (' + message + ');</script> "; //httpcontext.current.response.write (JS);  if (!page. Clientscript.isstartupscriptregistered (page. GetType (), "alert")   {  page. Clientscript.registerstartupscript (page. GetType (), "alert", JS); }  #endregion  }   /**////<summary> ///popup message box and move to the new URL  ///</summary> ///<param name= "messages" > Message content </param> ///<param name= "Tourl" > Connection address </param>  public static void Alertandredirect (String message, String tourl, page page)   {  # region  string js = "<script Language=javascript>aleRT (' {0} '); Window.location.replace (' {1} ') </script> "; //httpcontext.current.response.write (String. Format (JS, message, Tourl));  if (!page). Clientscript.isstartupscriptregistered (page. GetType (), "Alertandredirect"))   {  page. Clientscript.registerstartupscript (page. GetType (), "Alertandredirect", String. Format (JS, message, Tourl)); }  #endregion  }   /**////<summary> ///back to History page  ///</summary> ///<param name= "value" >-1/1</param>  public static void Gohistory ( int value, page page)   {  #region   String js = @ "<script language= ' JavaScript ' >  history.go ({0} );  </Script> "; //httpcontext.current.response.write (String. Format (JS, value));  if (!page. Clientscript.isstartupscriptregistered (page. GetType (), "Gohistory"))   {  page. Clientscript.registerstartupscript (page. GetType (), "Gohistory", String. Format (JS, value)); }  #endregion &nbsP }   /**////<summary> ///Refresh parent window  ///</summary>  public static void Refreshparent ( String URL, page page   {  #region   String js = @ "<script language= ' JavaScript ' >  window.opener . location.href= ' "+ URL +" '; Window.close ();</script> "; //httpcontext.current.response.write (JS);  if (!page. Clientscript.isstartupscriptregistered (page. GetType (), "refreshparent"))   {  page. Clientscript.registerstartupscript (page. GetType (), "Refreshparent", JS); }  #endregion  }     /**////<summary> ///brushes New open window  ///</summary>  public static void Refreshopener (Page page)   {  #region   String js = @ "<script language= ' JavaScript ' >  opener.location.reload ();  </Script>"; // HttpContext.Current.Response.Write (JS);  if (!page. Clientscript.isstartupscriptregistered (page. GetType (), "Refreshopener"))   {  page. ClIentscript.registerstartupscript (page. GetType (), "Refreshopener", JS); }  #endregion  }     /**////<summary> ///Dozen Open 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" > Left-Hand position </param>  public static void Openwebformsize (string URL, int width, int heigth, int top, int left, page page)   {  #region   String js = @ "<script language= ' J Avascript ' >window.open (' + URL + @ ', ', ' height= ' + heigth + ", width=" + width + ", top=" + Top + ", left=" + Left + ", l Ocation=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no '); </ Script> "; //httpcontext.current.response.write (JS);  if (!page. Clientscript.isstartupscriptregistered (page. GetType (), "OpenwebformSize ")   {  page. Clientscript.registerstartupscript (page. GetType (), "Openwebformsize", JS); }  #endregion  }     /**////<summary> // /Turn to URL-made page  ///</summary> ///<param name= "url" > Connection address </param>  public static void Javascriptlocationhref (string URL, page page)   {  #region   String js = @ "<script language= ' JavaScript ' >  window.location.replace (' {0} ');  </Script> ";  js = string. Format (JS, url); //httpcontext.current.response.write (JS);  if (!page. Clientscript.isstartupscriptregistered (page. GetType (), "Javascriptlocationhref"))   {  page. Clientscript.registerstartupscript (page. GetType (), "Javascriptlocationhref", JS); }  #endregion  }   /**////<summary> / Opens a modal dialog box for a specified size location  ///</summary> ///<param name= "Webformurl" > Connection address </param> /// <param name= "width" > Wide </param> ///<param name= "height" > High </param> ///<param name= "top" > Distance position </param>  ///<param name= "left" > Distance to position </param>  public static void Showmodaldialogwindow (string Webformurl, int width, int height, int top, int left, page page)   {  #region   String features = "Dialogwidt H: "+ 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, page);  #endregion  }   /**////<summary> ///pop-up modal window  /// ;/summary> ///<param name= "Webformurl" ></param> ///<param name= "Features" ></ param>  public static void Showmodaldialogwindow (string Webformurl, String features, page page)   {  str ing js = ShowmodaldialogjavasCript (Webformurl, features); //httpcontext.current.response.write (JS);  if (!page. Clientscript.isstartupscriptregistered (page. GetType (), "Showmodaldialogwindow"))   {  page. Clientscript.registerstartupscript (page. GetType (), "Showmodaldialogwindow", JS); } }   
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.