This tutorial will explain you how to a open popup window on button click event using C# & VB.NET in ASP.Net
<html> <head runat="server"> <title>ASP.Net - Open popup window on button click</title> </head> <body> <form id="frmPopupExample" runat="server"> <asp:Button ID="btnOpenPopupWindow" runat="server" Text="Open Popup Window" onclick="btnOpenPopupWindow_Click" /> </form> </body> </html>
protected void btnOpenPopupWindow_Click(object sender, EventArgs e) { int intId = 100; string strPopup = "<script language='javascript' ID='script1'>" // Passing intId to popup window. + "window.open('popup.aspx?data=" + HttpUtility.UrlEncode(intId.ToString()) + "','new window', 'top=90, left=200, width=300, height=100, dependant=no, location=0, alwaysRaised=no, menubar=no, resizeable=no, scrollbars=n, toolbar=no, status=no, center=yes')" + "</script>"; ScriptManager.RegisterStartupScript((Page) HttpContext.Current.Handler, typeof(Page), "Script1", strPopup, false); }
Protected Sub btnOpenPopupWindow_Click(sender As Object, e As System.EventArgs) Handles btnOpenPopupWindow.Click Dim intId As Integer = 100 ' Passing intId to popup window. Dim strPopup As String = "<script language='javascript' ID='script1'>" + "window.open('popup.aspx?data=" + HttpUtility.UrlEncode(intId.ToString()) + "','new window', 'top=90, left=200, width=300, height=100, dependant=no, location=0, alwaysRaised=no, menubar=no, resizeable=no, scrollbars=n, toolbar=no, status=no, center=yes')" + "</script>" ScriptManager.RegisterStartupScript(DirectCast(HttpContext.Current.Handler, Page), GetType(Page), "Script1", strPopup, False) End Sub