Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript
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 29-Nov-12 2:42am
danil33399
Comments
ryanb31 at 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: bad
good
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);
  Permalink  
Comments
danil33 at 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)

  Print Answers RSS
0 OriginalGriff 250
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 DamithSL 125
4 Afzaal Ahmad Zeeshan 120
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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