I need a new browser window to be opened to a give URL from VB code. How can I do this?
I know how to do it in javascript, but i need variables and functions from .NET to specify the acual URL, so I need the VB equivalent of window.open(...)
There is none but you can whip up a string that contains your javascript syntax <script language=javascript... then use the RegisterStartupScript method to write the javascript to the page. That javascript is then run when the page is returned to the browser.
Remember VB is a server side langauge and as such cannot directly affect what happens on the client. That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540
Johpje: One technique I use is to allow users to select a specific URL form a drop down box. The user selects a certain feature, say, e.g., a 1 meter aerial photograph located at TerraServer, and then the URL is attached to a simple Response.Redirect statement (I capture the Latitude and Longitude in the URL so the specific aerial opens up for that location). This may not be exactly what you're looking for but thought I'd mention it (a good technique). The code operates as follows:
After the user selects an item from the drop down listbox, they have to click on a "Map!" button to trigger the opening of the URL (you could alternatively set the AutoPostBack on the dd list). Name of listbox is ddMaps. Local variables strLat and strLong hold current Latitude/Longitude values.
& "&Lat=" & strLat & "&Long=" & strLong ..."
ElseIf...
End If
Simply concatenate the variables (Lat/Long) into the URL and TerraServer opens up at the right place. I have incorporated this technique at several locations thereby making it faster and more efficient to review data/charts/maps at the same time.
You submitted same time I did. I have benefited from your "append string" startup routines and that may serve in this purpose. Hope ya had a great holiday.
Thanks Izy! I did have a great holiday it was good to get away from work for a while. Yours went well also??
Johpje
Why is that going to be a lot of code? On the event that you want the new window to popup simply do something like this.
dim sb as new stringbuilder()
sb.append("<script language=javascript>"
sb.append("window.open('"
sb.append(somevariableholdingURL)
sb.append("')"
sb.append("</script>"
and thats it. A new window will open to whatever URL is held in somevariableholdingURL. That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540
johpje: Post the final solution. I'm curious. Zarc, spent a good deal of time over the holidays (for fun) funning ArcMap queries (watershed etc...). I want to hook up dot NET with ESRI's IMS system on the web - great combination; but first SQL Server! This year is booked. Thanks.
To be honest, i didn't use any of the above in the final solution. But I learned some new stuff, anyway.
What i did is make a html file that does nothing except for opening a new window with the requested page and redirect itself back to the original page.
I give for example URL .../openPage.htm?redirect=report
<script language="javascript">
<!--
report = (here i get the page name out of the URL)
window.open(report + '.html' , '_blank')
window.top.location.href = 'Home.aspx'
-->
</script>
And the first url i can easily construct in the VB part. and redirect with Response.Redirect(URL)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.