Solved

Page.ClientScript.RegisterStartupScript is not working

Posted on 2013-06-13
8
2,245 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now