简体   繁体   English

从Asp.net中的后台代码在iframe中打开页面

[英]Open a page in Iframe from code behind in Asp.net

How can I execute the following code as a JavaScript from the code behind file (against a button click). 如何从文件后面的代码中执行以下代码作为JavaScript(反对单击按钮)。

<a class="iframe2 cboxElement" href='<%# ResolveUrl("Project_MainPageEdit.aspx?editpid=1778" ) %>'>Project Details (edit)</a>

What I'm trying to do is, I am trying to open up Project_MainPageEdit.aspx as an IFrame using the above code. 我想要做的是,我正在尝试使用上述代码将Project_MainPageEdit.aspx作为IFrame打开。 It is working perfectly fine in a different aspx page, but does not work in this Page. 它在另一个aspx页中工作正常,但在此页中不起作用。 When click on 'Project Details' link, Iframe opens up, but nothing shows up. 点击“项目详细信息”链接后,iframe会打开,但不会显示任何内容。 What is the reason? 是什么原因?

I'm thinking if I call the above code from code behind using JavaScript it might work? 我在想,如果我从后面使用JavaScript的代码中调用上述代码,那可能行得通吗?

You cannot call a function from code-behind using Javascript, unless you are using node.js, which is obviously not the case here. 除非您使用的是node.js,否则无法使用Javascript从代码隐藏中调用函数,这显然不是这种情况。 Also, the structure you are using is not an iframe , it is an anchor. 另外,您使用的结构不是iframe ,而是锚点。 If you mean that it is inside an iframe , then you should check whether the page exists, the path you are referring to is correct and whether you get any exceptions/errors. 如果您认为它位于iframe ,则应检查该页面是否存在,所引用的路径是否正确以及是否有任何异常/错误。 You should debug your code, but check the url as well. 您应该调试代码,但同时还要检查URL。 If you open your browser console and inspect the given element, is its href corresponding to the expected one? 如果打开浏览器控制台并检查给定的元素,它的href对应于预期的元素?

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

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