views:

235

answers:

2

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 calling 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?

+1  A: 

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>.

SLaks
A: 

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" />
Chris Stewart
That's exactly what I meant.
SLaks
I can see it now, but it wasn't quite descriptive enough at the time. Appreciate the point in the right direction.
Chris Stewart