While using silverlight, is there a way to use a button to change the webpage?
I have an AS开发者_如何学CP.MVC application which has a silverlight app inside. I want to change the page when I click one of my buttons. Is there a way to make it?
I think the HtmlPage.Navigate method is probably what you're looking for.
You'll need the following using statement:
using System.Windows.Browser;
HtmlPage.Window.Navigate(new Uri("http://www.mypage.com/newPage.html"));
Just stick this guy in the click event of your button and it should do what you want.
Also, if you wish to navigate within your website, you can use a Relative URI, like so:
HtmlPage.Window.Navigate(new Uri("newPage.html", UriKind.Relative));
What should be done is to use the using System.Windows.Browser;
statement, and the, in the click method, add the following code:
HtmlPage.Window.Navigate(new Uri("http://yourpagegoeshere.com"));
Thanks overhed!
精彩评论