如何在MVC中打开iframe [英] How to open iframe in MVC

查看:466
本文介绍了如何在MVC中打开iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在iframe中打开局部视图,但它不起作用。



什么我曾尝试:



Hi,

I want to open partial view in iframe but its not working.

What I have tried:

partial view : <pre>@Html.RenderPartial("_ABC", model);





i想在iframe中打开





i want to open in iframe

<iframe src='@{Html.RenderPartial("_ABC", model);}' id='fram' ></iframe>





以上代码将在src中添加数据,但html为空。

所以任何人都可以帮我如何在iframe中打开局部视图



谢谢...



above code will add the data in src but html is blank.
so any one can help me how to open partial view in iframe

Thanks...

推荐答案

iframe的src是iframe中显示的url。视图没有您可以导航到的URL,因此您需要一个返回视图的控制器操作,您必须将src设置为控制器操作的URL。



你也可以使用srcdoc属性而不是src,但是根据视图中的内容,这可能不是一个好的选择。
The src of the iframe is the url to show in the iframe. Views don't have urls you can navigate to so you'll need a controller action that returns your view and you'll have to set the src to the url of the controller action.

You could also use the srcdoc attribute rather than src but depending on what's in your view that's probably not a good option.


这篇关于如何在MVC中打开iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆