Solved

Page.ClientScript.RegisterStartupScript is not working

Posted on 2013-06-13
8
2,715 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 166 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 13

Accepted Solution

by:
Jitendra Patil earned 334 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 334 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

632 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