Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Page.ClientScript.RegisterStartupScript is not working

Posted on 2013-06-13
8
Medium Priority
?
2,869 Views
Last Modified: 2013-07-09
Hi,
I am trying to open a window and passing the parameters in button click event in .Net 3.5 application,VS 2010.
I added this code in button_click event:

Page.ClientScript.RegisterStartupScript(this.GetType(), "Pop up", "<script language='javascript'>" + "window.open('/Forms/AddNewInfo.aspx?param1=" + txtbx1.Text.Trim() + "&param2=" + txtbx2.Text.Trim() + "',null,'height=1000, width=1000,status= no,resizable= yes, scrollbars=yes, toolbar=no,location=no,menubar=no ');</script>");

Any suggestions please.

Thanks
0
Comment
Question by:KavyaVS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 21

Assisted Solution

by:Craig Wagner
Craig Wagner earned 498 total points
ID: 39246235
My suggestions would be to not make a round trip to the server and instead handle this all in client-side JavaScript.

    <asp:TextBox ID="txtbx1" runat="server"></asp:TextBox><br />
    <asp:TextBox ID="txtbx2" runat="server"></asp:TextBox><br />
    <button type="button" onclick="openWindow();">Go</button>

    <script>
        function openWindow() {
            var txtVal1 = document.getElementById("<%= txtbx1.ClientID %>").value;
            var txtVal2 = document.getElementById("<%= txtbx2.ClientID %>").value;

            window.open("/Forms/AddNewInfo.aspx?param1=" + txtVal1 + "&param2=" + txtVal2, null, 'height=1000,width=1000,status=no,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no');
        }
    </script>
0
 
LVL 13

Expert Comment

by:Jitendra Patil
ID: 39247055
hi KavyaVS

i've tried your code its working fine here.
may be there would be a path problem within the script just try this way

Page.ClientScript.RegisterStartupScript(this.GetType(), "Pop up", "<script language='javascript'>" + "window.open('~/Forms/AddNewInfo.aspx?param1=" + txtbx1.Text.Trim() + "&param2=" + txtbx2.Text.Trim() + "',null,'height=1000, width=1000,status= no,resizable= yes, scrollbars=yes, toolbar=no,location=no,menubar=no ');</script>");

as your code is working as expected.

hope this helps.
0
 

Author Comment

by:KavyaVS
ID: 39260896
I tried this after changing the path.But still the page is not opening up in new window.
I am using Ajax toolkit and update panel in the page.
Is anything prevent opening the page?

Page.ClientScript.RegisterStartupScript(this.GetType(), "Pop up", "<script language='javascript'>" + "window.open('~/Forms/AddNewInfo.aspx?param1=" + txtbx1.Text.Trim() + "&param2=" + txtbx2.Text.Trim() + "',null,'height=1000, width=1000,status= no,resizable= yes, scrollbars=yes, toolbar=no,location=no,menubar=no ');</script>");

Thanks
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 13

Accepted Solution

by:
Jitendra Patil earned 1002 total points
ID: 39265984
1. check  your browser setting if javascript is not disabled.

2. may be your update panel would be creating problem opening the javascript popup, if so you need to call appropriate upcontrols.update  method.

just a small hack try setting the UpdateMode Property of updatepanel to "Conditional"

for more just refer the this link UpdatePanel.UpdateMode Property
if still it does not work then just post you (.aspx code for ajaxtoolkit control and with updatepanel.
hope this helps.
0
 

Author Comment

by:KavyaVS
ID: 39287659
Hi patil786,
I checked my browser. JavaScript is not disabled.
Please find the attached  .aspx code and code behind files.
Please let me know if I need to make any changes.

Thanks
Default2-062913.txt
Default-code.txt
0
 
LVL 13

Assisted Solution

by:Jitendra Patil
Jitendra Patil earned 1002 total points
ID: 39288064
you are missing a table cell closing tag.

close the tab after your update control id="updMainList" ends.

please check your aspx code properly it contains non matching table ending tags.

try this one i am still referring your code as i don't have ajaxcontrol toolkit installed here.

hope this helps.
0
 

Author Comment

by:KavyaVS
ID: 39296713
I checked and closed all the tags and changed the aspx page.
Please see the attached aspx page. It's still not opening the page in new window.

Thanks
Default2-070313.txt
0
 

Author Closing Comment

by:KavyaVS
ID: 39312479
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question