How to load view (cshtml) in iframe?

I am trying to load a view in an iframe into another (parent) view using javascript and a razor.

I tried installing iframe src for this  var url = '@Url.Action("myaction", "MyController")';

and this:   var url = '@Href("~/myform.cshtml")'; without success.

thanks

thanks

+4
source share
2 answers

If you are using a razor motor.

<iframe src = '@Url.Action("myaction", "myController")' width = "100%" 
    height="1000" frameBorder="0"></iframe>
+5
source

Set the src attribute for the iframe to the action url.

Example:

<iframe src ='home/index'></iframe>

Verify that the attribute srcURL is replaced by the action URL.

An alternative way to Razor:

<iframe src ='@Url.Action("action name")'></iframe>
+1
source

All Articles