2

I am trying to figure out if I have something wrong with my architecture, or if I am just in need of a quick fix.

I have the following on my page:

<div ID="UploadDashboardDecorationZone">
    <fieldset id="UploadDashboard">
        <legend>Upload Dashboard</legend>
        <telerik:RadUpload ID="UploadDashboardSelector" Runat="server" Width="235px" AllowedFileExtensions=".xml"  MaxFileInputsCount="1" ControlObjectsVisibility="None" />
    </fieldset>        
    <div class="BottomButton">
        <telerik:RadButton ID="SubmitUploadDashboardButton" Runat="Server" Text="Upload" OnClientClicked="CloseUploadDashboard" />  
    </div>
</div>

The user selects a file they wish to upload, then they press the SubmitUploadDashboardButton.

I then have the following server-side code:

protected void Page_Init(object sender, EventArgs e)
{
    if (Request.Files.Count > 0) HandleUploadedFile();
}

This all works great. The uploaded file is responded to and I see the changes on my page. The only problem is that I have left my page's request HTTP Method as POST and not GET. This means that bad things will happen if the user refreshes the page.

Previously, I had used the following code-snippet to resolve this issue:

Page.Response.Redirect(Page.Request.Url.ToString(), true);

Unfortunately, this does not work for me anymore. I don't want the flashing that happens with reloading the page (in addition to some code issues that arise with reloading).

What are my other options here? If I wrap UploadDashboardDecorationZone with an UpdatePanel, then Request.Files comes out as 0.

Is there a quick code-fix for this that is common? Or am I missing something deeper in my understanding of how the file upload process works?

Thanks.

Sean Anderson
  • 27,963
  • 30
  • 126
  • 237
  • Using DevExpress, I once read that they provide an upload method that POSTs to a hidden IFRAME and therefore is "transparent" in terms of refreshing the main page. Maybe you could configure your Telerik control in this way, too? – Uwe Keim Nov 04 '11 at 22:20
  • I will have to do some reading on this method. Thank you for the suggestion! :) – Sean Anderson Nov 04 '11 at 22:23
  • In a recent project, I successfully used the HTML 5 File API which does uploading of the files through XmlHttpRequest object (aka AJAX) which also has no full page POST). Requires modern browsers, though. – Uwe Keim Nov 04 '11 at 22:25
  • Any idea if it is supported by IE8? That's the only non-modern browser in my requirements. I'll check it out -- I'm reading a blog about it right now. From the blog's time of writing it sounds like only IE9 supports it. Shoot. – Sean Anderson Nov 04 '11 at 22:27
  • 1
    Unfortunately not. Even IE9 does not support this fully :-( See the code snippet in [my SO question for a list of supported browsers](http://stackoverflow.com/questions/7772416). – Uwe Keim Nov 04 '11 at 22:29

1 Answers1

1

I don't know of a way to get around the "flash" when the page changes unless you do your calls using Ajax which doesn't require the page to reload at all.

John
  • 6,503
  • 3
  • 37
  • 58
  • 1
    I am OK with the flash from the button submitting. I am not OK with a second flash as I call Page.Response.Redirect. Sorry for being unclear there. :) – Sean Anderson Nov 04 '11 at 22:21