开发者

Using Response.Redirect with jQuery Thickbox

开发者 https://www.devze.com 2022-12-30 23:50 出处:网络
I\'m using jQuery Thickbox to display an iframe (upload.aspx) that allows a user to upload a file.In the code behind for the upload.aspx I finish by sending:

I'm using jQuery Thickbox to display an iframe (upload.aspx) that allows a user to upload a file. In the code behind for the upload.aspx I finish by sending:

Response.Redirect("blah.aspx");

The page I redirect to is dynamic based on the results of the upload process. When this redirect happens, it happens inside the Thickbox and not the parent window as I'd like it to. Here's the ca开发者_Python百科lling ASP.NET page (home.aspx):

<a href="upload.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=300&width=500&modal=true" class="thickbox">Add New</a>

And here's the submit button inside of the upload.aspx page:

<asp:Button ID="btnUpload" runat="server" Text="Upload" 
     OnClick="btnUpload_Click" OnClientClick="self.parent.tb_remove();" />

This is designed to close the modal window and send control to the code behind to perform the file upload, processing, etc.

Has anyone experienced this before? How would I go about sending a redirect on the parent window?


You cannot send a redirect to a parent frame.

Instead, you need to use Javascript.

You can write top.location = "whatever"; in Javascript in the <iframe>.


Here's what I ended up doing.

Added server tags to the body element of upload.aspx:

<body id="mBody" runat="server">

Removed the Response.Redirect, and attached some JavaScript to run on the next load.

HtmlGenericControl body = (HtmlGenericControl)Page.FindControl("mBody");
body.Attributes.Add("onload", "window.top.location.href='blah.aspx';");

And removed the client click from the button:

<asp:Button ID="btnUpload" runat="server" Text="Upload" 
    OnClick="btnUpload_Click" />
0

精彩评论

暂无评论...
验证码 换一张
取 消