?
Solved

net code behind calling window.open

Posted on 2009-05-08
3
Medium Priority
?
585 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 1500 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

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…

801 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