Solved

net code behind calling window.open

Posted on 2009-05-08
3
583 Views
Last Modified: 2013-12-17
Using .net c# and code behind on button click gets the url from a database and tries to call javascript with variable found and open new web browser window - but code fails as no window created and error message

Error in sys.webforms.pagerequestmanagerparserexception - the message from the server could not be parsed error parsing near <script type='text/

Cannot use aspx page as dont know vlaue in that page only in code behind

Any help please!

// addresess from database call           
 string cAddress = "rgl group so51 6al";
string cUrl = "http://maps.google.co.uk/maps?ie=UTF-8&hl=en&tab=wl&q=" + cAddress;
string cScript = "<script  type='text/javascript'> window.open('" + cUrl + "');</script>";
 Response.Write(cScript);

Open in new window

0
Comment
Question by:stephenwilde
[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
  • 2
3 Comments
 
LVL 12

Expert Comment

by:GuitarRich
ID: 24334239
You could write a method in the code behind to get the Url from the database and then put that into the aspx page using AddAttributes
<asp:Button runat="Server" id="openButton" text="Open"></asp:Button>

In Page_Load:
 
string cAddress = "rgl group so51 6al";
string cUrl = "http://maps.google.co.uk/maps?ie=UTF-8&hl=en&tab=wl&q=" + cAddress;
openButton.OnClientClick = "javascript:window.Open("javascript:window.open('" + cUrl + "')";

Open in new window

0
 
LVL 12

Accepted Solution

by:
GuitarRich earned 500 total points
ID: 24334243
sorry that should be using OnClientClick not AddAttributes
0
 

Author Comment

by:stephenwilde
ID: 24334503
Thanks for yor quick replies

In page load the record required is not known and it is an ajax page so not sure if page event is fired again as in ajax panel

Rgds
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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