简体   繁体   English

如何从SilverLight应用程序在新的浏览器窗口中打开aspx页面?

[英]How can I open an aspx page in a new browser window from a SilverLight Application?

I want to add a button to my user control in SilverLight 4.0 application which will open a new browser window with an aspx in it when it is clicked. 我想在SilverLight 4.0应用程序的用户控件中添加一个按钮,该按钮将在单击时打开一个带有aspx的新浏览器窗口。

How can I achieve this, can you please advice? 我该如何做到这一点,请您指教?

Additionaly, can I lock the SL application until this new window is closed (Alike a modal dialog)? 另外,我可以锁定SL应用程序,直到关闭新窗口(就像模式对话框一样)吗?

thanks! 谢谢!

Use the HyperlinkButton control. 使用HyperlinkBut​​ton控件。 You can specify to open in a new tab or new browser window. 您可以指定在新标签页或新浏览器窗口中打开。

(There is also a navigate option available from the Http class, but I will have to look up the syntax). (Http类也提供了一个导航选项,但是我将不得不查找语法)。

To do the modal popup scenario, you would need to generate a popup in Javascript on the browser hosting the SL control (which you can trigger from within Silverlight). 要执行模式弹出场景,您需要在托管SL控件的浏览器中使用Javascript生成弹出窗口( 可以从Silverlight中触发)。

You can open a new window with:- 您可以使用以下方法打开一个新窗口:

 HtmlPage.Window.Navigate(uriToNewPage, "_blank");

However modal dialogs depend on the specific browser that is hosting. 但是,模式对话框取决于托管的特定浏览器。 Internet Explorer and Firefox both have a showModalDialog method on their window objects. Internet Explorer和Firefox在其window对象上都有一个showModalDialog方法。 You would need to use the Invoke method to fire these:- 您将需要使用Invoke方法来触发这些操作:

 HtmlPage.Window.Invoke("showModalDialog", urlString);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM