Introduction
This code is helpful for opening Popup window in ASP.NET using c#
Paragraph Heading 1
//*** Place this on the Page_Load Event in Asp.net)****//
OpenPopUp(HelpBtn, "txt.aspx", "Help", 650, 450);
Paragraph Heading N //******** This is a Separate function*******//
public static void OpenPopUp (System.Web.UI.WebControls.WebControl opener, string PagePath) { string clientScript; //***Building the client script- window.open***// clientScript = "window.open(\'" + PagePath + "\')"; //***regiter the script to the clientside click event of the 'opener' control**// opener.Attributes.Add("onClick", clientScript); } public static void OpenPopUp (System.Web.UI.WebControls.WebControl opener, string PagePath, string windowName, int width, int height) { string clientScript; string windowAttribs; //Building Client side window attributes with width and height.// //Also the the window will be positioned to the middle of the screen// windowAttribs = "width=" + width + "px," + "height=" + height + "px," + "left=\'+((screen.width -" + width + ") / 2)+\'," + "top=\'+ (screen.height - " + height + ")/ 2+\'"; //***Building the client script- window.open, with additional parameters***/// clientScript = "window.open(\'" + PagePath + "\',\'" + windowName + "\',\'" + windowAttribs + "\');return false;"; //regiter the script to the clientside click event of the 'opener' control*****/// opener.Attributes.Add("onClick", clientScript); }
Summary
This code is helpful for those Programmers whose have less knowlegde about HTML..
|
No responses found. Be the first to respond and make money from revenue sharing program.
|