ASP.NET + jQuery UI Modal: load aspx page into modal dialog

I need to load aspx page into jQuery UI’s modal dialog window. I used following approach: load page content via ajax call into dialog’s div and show it:$.get(‘Page.aspx’, function(response) $(‘#dialog’).html(response); $(“#dialog”).dialog(‘open’););but I’ve got very strange error (IE8) in line 137215738 (!): ‘…

via Asp.Net Developed Tutorials » Search Results » ajax:

ASP.NET + jQuery UI Modal: load aspx page into modal dialog

I need to load aspx page into jQuery UI’s modal dialog window. I used following approach: load page content via ajax call into dialog’s div and show it:
$.get(‘Page.aspx’, function(response)
$(‘#dialog’).html(response);
$(“#dialog”).dialog(‘open’);
);but I’ve got very strange error (IE8) in line 137215738 (!): ‘theForm.elements.length’ – is null or not an object. JS debbuger says that source code is not available for such location. I have an assumption that this error happens because of multiple ‘form’ tags that appears on page after ajax call
I wonder, how can i fix this? Or maybe some other way of showing aspx page in modal dialog?
……………………………………..

You cannot fully embed one ASPX page’s content within another for a couple of reasons:
You would be nesting tags in a non-sensical way.
You are polluting one page’s javascript state with the other’s.
You need to render Page.aspx as a partail view, rather than including the entire payload of an ASPX page.
I’m not 100% sure if you can do this in plain-old-asp.net without calling the Render function of individual controls, using the Response stream as the target.
In ASP.NET-MVC, however, you can use a PartialView result.
……………………………………..

What about putting an IFRAME in the modal, and setting the IFRAME src to Page.aspx?
……………………………………..

right click on your web project in Visual Studio and add new generic HTTP handler. The code will look like this:
DialogContentHandler.ashx:
public class DialogContentHandler: IHttpHandler

public void ProcessRequest(HttpContext context)

context.Response.ContentType = “text/plain”;
string s = getDialogContent();
context.Response.Write(s);

public bool IsReusable

get

return true;

}
}aspx code:
$.get(‘DialogContentHandler.ashx’, function(response)
$(‘#dialog’).html(response);
$(“#dialog”).dialog(‘open’);
);
……………………………………..

Solved by creating generic HTTP handler and writing to the response only nessesary html markup.

For more info: ASP.NET + jQuery UI Modal: load aspx page into modal dialog

Asp.Net Developed Tutorials » Search Results » ajax

ASP.NET + jQuery UI Modal: load aspx page into modal dialog

Share this post:

Related Posts

Leave a Comment