This is a migrated thread and some comments may be shown as answers.

How do you render a View in an iframe?

4 Answers 152 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Derek Hunziker
Top achievements
Rank 1
Derek Hunziker asked on 27 Aug 2010, 12:02 AM
Hi there,

It seems that the default behavior for the MVC Window is to dynamically render the view inline with the current page.

.LoadContentFrom("_MyView", "MyController")

This is great for static content, but makes it nearly impossible to create complex wizards and forms in the window.

For example, using server validation appears to be impossible since you would need to return the model to the view. Furthermore, the built-in MVC client validation doesn't appear to work in a form embedded in a window.

That said, is there any plans on rendering the view in an iframe instead of inline? Is there a workaround for now?

Many thanks!

4 Answers, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 27 Aug 2010, 08:06 AM
Hello Derek,

You can easily render an iframe using the Content(Action) method:

    .Content(() => { %>
        <iframe src="<%= Url.Action("_MyView", "MyController") %>" frameborder="0" style="width: 100$; height: 100%"></iframe>
    <% })
    .Scrollable(false)


We don't have plans for embedding this behavior in the window; we will, however, look into the validation issue. Wizards will be a great example in the online demos -- they are a common use-case.

Greetings,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Derek Hunziker
Top achievements
Rank 1
answered on 30 Aug 2010, 10:51 PM
Great thanks. This seems to be working.

Another question that stemmed from this is how to close the pop-up window after my modal/wizard form is submitted. I can't seem to find a way to get a handle on the popup window from within the iframe.

I would also be interested in a method for destroying the window OnClose so that my form is reset the next time the window is opened.

Many thanks!
0
Alex Gyoshev
Telerik team
answered on 31 Aug 2010, 07:54 AM
Hello Derek,

You can get the iframe's parent window (through window.parent) and get the window handle from there, using jQuery (i.e. window.parent.$('#MyWindow').data('tWindow').close();).

Regarding your second question, isn't it that you want to change the iframe URL once the window is closed? You can destroy the window by calling its client-side destroy() method, but it will remove its HTML and you won't be able to open it again (unless you re-create it with the create() client-side method).

Regards,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alejandro
Top achievements
Rank 1
answered on 04 Nov 2010, 09:33 PM
Hi,

Tk for this information, is very good and resolve my problem is validation page in to telerik window.

Saludos desde COLOMBIA Medellin.
Tags
Window
Asked by
Derek Hunziker
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Derek Hunziker
Top achievements
Rank 1
Alejandro
Top achievements
Rank 1
Share this question
or