How to post only a specific ASCX partial instead of the whole page
- by Hallaghan
I've got an ASPX page rendering a search ascx page which in turn will fill a grid on the main ASPX page.
Aside that, I've also got an ascx page which uploads files, like this:
<form method="post" action="<%= Url.Action("UploadFile") %>" enctype="multipart/form-data">
<fieldset>
<input type="file" name="file" id="file" />
<%=Html.ButtonSubmit("Upload") %>
</fieldset></form>
Here's the problem: imagine I have searched for a single entry to be displayed on the grid. The grid displays this single entry and after wards, I upload a file and press the button "Upload". The whole page gets posted and the content in the grid is lost, now displaying all the results available.
What could I do to prevent this from happening, maintaining the grid state (we're not using ViewState) or otherwise not posting back the whole page but only the ascx with the file upload?
Note: I'm new to MVC.