This is a migrated thread and some comments may be shown as answers.

Working with Request.Files and Changing from POST to GET without reloading page?

3 Answers 104 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 05 Nov 2011, 12:01 AM
Hi Telerik,

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:

<csw:UploadDashboardRadWindow ID="UploadDashboardWindow" Runat="Server">
    <ContentTemplate>
        <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>
    </ContentTemplate>
</csw:UploadDashboardRadWindow>

and the following server-side code:

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

HandleUploadedFiles() works perfectly fine, but I am left with my Request's HTTPMethod set to POST and not GET. This means that if the user tries to refresh my Web Application they are prompted with a confirm form resubmission alert.

Previously, I had fixed this with the following:

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

But new additions to my code makes this a non-acceptable solution. Namely, I have implemented Start Edit / Cancel Edit / Save Changes -- and refreshing the page is analogous to 'Cancel Edit.' As such, refreshing via code isn't a possibility.

Could you show me how to parse an uploaded file while keeping the RadWindow wrapped in an update panel? Whenever I try to do it, Request.Files.Count is 0. 

Thanks

3 Answers, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 09 Nov 2011, 07:21 PM
Hello Sean,

Please note that it is not possible to use RadUpload control into update panel - limitation of the
XmlHttpRequest object. You need to do a regular postback.
For more details review the following help article.

In case that the problem is not connected with described above, please provide me a working sample project that reproduces your issue.

Kind regards,
Peter Filipov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Sean
Top achievements
Rank 2
answered on 10 Nov 2011, 12:35 AM
Hi Peter,

No sample project to provide as it is reproducible on RadUpload - First Look. Go to this page, select any file and click upload. Now, refresh the page. 

You will be prompted with a 'Confirm Form Resubmission' dialog, varying by browser. This is because Request's HTTPMethod is being left as 'POST' and not 'GET'.

I would like to know how to craft my code such that this message does not occur without using the provided Response.Redirect code-snippet.

I am OK with the initial page reload -- that is expected, but I would like the user to be able to refresh the page without any negative consequences.

Sean
0
Peter Filipov
Telerik team
answered on 11 Nov 2011, 05:01 PM
Hi Sean,

As far as I researched about resubmission of the form, I found out that the way to avoid resubmission is to implement PRG pattern and it is with redirection.

I will be glad to assist you again.

Best wishes,
Peter Filipov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Upload (Obsolete)
Asked by
Sean
Top achievements
Rank 2
Answers by
Peter Filipov
Telerik team
Sean
Top achievements
Rank 2
Share this question
or