Click here to Skip to main content
14,665,301 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
Iam trying to view a popup window while clicking on a button, using javascript.But with the following code Iam unable to get a popup window,it just open up another page.Is it possible to modify this code and obtain a popup window?

Code here:-

<%@ Page Language="C#" %>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    <script runat="server">


        protected void Button1_Click(object sender, EventArgs e)
        {

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('http://localhost:49911/UI/Report1.aspx','width=100,height=100,scrollbars=no');", true);
        }
    </script>


    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>


        <script type="text/javascript">


            function pageLoad() {
            }


        </script>


    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
        </div>


        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        </form>
    </body>
    </html>




please Help.
Posted
Comments
ZurdoDev 29-Nov-12 8:37am
   
I would just use an html input button and onclick call a function that does the window.open. Or, use the OnClientClick event of your ASP.Net button and after calling window.open call return false; so that the page does not post back.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Try the following code
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('http://localhost:49911/UI/Report1.aspx','_blank','width=100,height=100,scrollbars=no');", true);
   
Comments
danil33 29-Nov-12 22:59pm
   
Hi,
Thanks for the replies.Now also a new page is opening,but in small size.But actually what I want is not a new page just a popup window.On clicking on a button in the popup window will save all the details in the popup and returns to the currentpage.

Sorry for the confusions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100