I currently a have a popup panel that contains a fileupload control and some other textboxes. What I wanted to do is to create a cancel button that closes the popup panel and reload the page to clear the data from textboxes and fileupload control. I also have an error page wherein if the user uploads a file greater than 15mb, it will throw. The problem is, every time I refresh the page from the server side using Response.Redirect(Request.Url.ToString())
, the server still fetches the file that is contained in the fileupload control(Maybe putting it in memory? --Sorry I'm bad at this--) and throws the error page if greater than 15mb. I suspect this is because of the fileupload behavior for any postback it encounter. How can I achieve this close and reload?
Code:
...
<td>
<label>Upload: </label>
</td>
<td>
<asp:FileUpload ID="fileUpload" runat="server" CssClass="fileupload"/>
</td><table>
<br />
<asp:Button ID="btnSave" ValidationGroup="UpdateSlide" runat="server" Text="Save" CssClass="modal-buttons" OnClick="btnSave_Click"/>
<asp:Button ID="btnCancel" CausesValidation="false" runat="server" Text="Cancel" CssClass="modal-buttons" OnClick="btnCancel_Click"/>
<br />
Code Behind:
protected void btnCancel_Click(object sender, EventArgs e){
Response.Redirect(Request.Url.toString());
}
Error Page Code:
protected void Page_Load(object sender, EventArgs e)
{
HtmlMeta meta = new HtmlMeta();
string path = Request.UrlReferrer.ToString();
Literal str = new Literal();
meta.HttpEquiv = "Refresh";
meta.Content = "5;url=" + path;
str.Text = "<h1 style='color: red; font-size: xx-large;'>IIS Error 404.13</h1><h2 style='font-size: large'>File upload too large!</h2><p style='color: midnightblue;'>Maximum allowed file size: <b style='color:red;'>15mb</b></p><p>Redirecting...</p>";
this.Page.Controls.Add(str);
this.Page.Controls.Add(meta);
}
Web.config:
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="15728640"></requestLimits>
</requestFiltering>
</security>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="13"/>
<error statusCode="404" subStatusCode="13" prefixLanguageFilePath="" path="/Error Pages/Error_A.aspx" responseMode="Redirect"/>
<!--<error statusCode="404" prefixLanguageFilePath="" path="/Error Pages/ERROR_B.aspx" responseMode="Redirect"/>-->
</httpErrors>
I also tried this from the client side using javascript window.location.reload()
but to no avail. (It reloads successfully without posting back to the server but doesn't close the modalpopupextender panel.)