Solved

Page.ClientScript.RegisterStartupScript is not working

Posted on 2013-06-13
8
2,560 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 12

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

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 12

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

734 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