Solved

Page.ClientScript.RegisterStartupScript is not working

Posted on 2013-06-13
8
2,435 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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