简体   繁体   English

在ASP.Net中的iFrame中打开MenuItem URL

[英]Open MenuItem URL in iFrame in ASP.Net

I have a dynamically generated menu (C#), like this: 我有一个动态生成的菜单(C#),如下所示:

MenuItem(string text, string value, string imageUrl, string navigateUrl, string target)

MenuItem AdminLevel1 = new MenuItem("Admin", "Admin"); MenuItem AdminPedidosRegisto = new MenuItem("Questions", "AdminQ");
NavigationMenu.Items.Add(new MenuItem("Messages Received", "AdminMessagesR", "", "./Admin/Messages.ascx", "ContainerIframe")); AdminPedidosRegisto.ChildItems.Add(new MenuItem("Pending", "AdminPending", "", "./Admin/Pedidos.ascx", "ContainerIframe"));

Where 'ContainerIframe' is the iFrame's ID and 'NavigationMenu' is the (asp:Menu)'s ID. 其中“ ContainerIframe”是iFrame的ID,“ NavigationMenu”是(asp:Menu)的ID。

I want the URL in navigateUrl to open in an iFrame. 我希望NavigationUrl中的URL在iFrame中打开。 Is that possible? 那可能吗? If i set the iFrame's ID in the target parameter, in google chrome it works fine, but not in the other browsers. 如果我在目标参数中设置了iFrame的ID,则在google chrome中可以正常运行,但不能在其他浏览器中运行。 Is there a way? 有办法吗?

Use the name of the iframe and not the id to archive that, to load the page inside the iframe. 使用iframe的name而不是id进行存档,以将页面加载到iframe中。

eg: 例如:

<iframe src="whatever.htm" id="whateverid" name="ContainerIframe"></iframe>

You can have the same id and name, but the important here is the name 您可以使用相同的ID和名称,但重要的是name

Here is an iframe test that work: http://jsfiddle.net/7AMjy/3/ 这是一个有效的iframe测试: http : //jsfiddle.net/7AMjy/3/

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

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