Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Show new browser window
8 replies. Latest Post by dumbledad on November 19, 2007.
(0)
JasonLP
Member
16 points
14 Posts
05-23-2007 7:18 PM |
I'd like to have a new browser window popup with a given URL when the user clicks on a certain UI element. Is this possible? In .NET, I know I can use System.Diagnostics.Process.Start(), but this isn't available in the Silverlight realm. I know I can also use System.Windows.Browser.HtmlPage.Navigate(), but this replaces the current page (wiping out the Silverlight control), which is not what I need either. Is there any way to load a page into a new browser window?
Thanks!
-Jason-
chad.cam...
Participant
1918 points
332 Posts
05-23-2007 8:25 PM |
Hi Jason,
This is possible. If you are using JavaScript to handle your logic, on a ui element click, you can use the HTML DOM to launch a new browser window. Here is some reference: http://www.w3schools.com/htmldom/met_win_open.asp
If this answers your question, please select "mark as answer"
Thank you,
Chad Campbell
05-23-2007 9:12 PM |
I am using C# to handle the logic. Is there a way to call into a Javascript function on the page that is hosting the Silverlight control?
05-23-2007 9:20 PM |
I have not had a chace to play with the 1.1 framework yet. I hope to soon. I would recommend looking in the "System.Windows.Browser" namespace. But I do not know
http://download.microsoft.com/download/f/2/e/f2ecc2ad-c498-4538-8a2c-15eb157c00a7/SL_Map_FinalNET.png
Dave Relyea
1084 points
249 Posts
05-23-2007 11:43 PM |
See my blog post for one way to call JS from C#.
http://blogs.msdn.com/devdave/archive/2007/05/21/calling-javascript-from-c.aspx
huanwu
152 points
32 Posts
05-24-2007 2:35 PM |
If you use HtmlPage.Navigate("http://www.msn.com", "new window"), then it will not replace the current page but pop up with a new window named "new window".
05-24-2007 2:49 PM |
Dave,
This works great. Thank you!
05-24-2007 2:51 PM |
I didn't know this overload existed.
Thanks for this!
dumbledad
38 points
8 Posts
11-19-2007 12:28 PM |
That almost works for me. System.Windows.Browser.HtmlPage.Navigate("http://silverlight.net/", "new window");causes a COMException in the SilverLight DLL with the additional information "Navigate failed". But System.Windows.Browser.HtmlPage.Navigate("http://silverlight.net/", "_blank");opens the Silverlight homepage in a new tab, though the browser does not swap to it. Are the target options for System.Windows.Browser.HtmlPage.Navigate documented anywhere?