Reputation: 1823
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?
Upvotes: 3
Views: 7000
Reputation: 1823
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');
});
Upvotes: 2
Reputation: 1823
Solved by creating generic HTTP handler and writing to the response only nessesary html markup.
Upvotes: -1
Reputation: 19870
What about putting an IFRAME in the modal, and setting the IFRAME src to Page.aspx?
Upvotes: 6
Reputation: 49564
You cannot fully embed one ASPX page's content within another for a couple of reasons:
<html>
tags in a non-sensical way.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.
Upvotes: 4