How to post only a specific ASCX partial instead of the whole page

Posted by Hallaghan on Stack Overflow See other posts from Stack Overflow or by Hallaghan
Published on 2010-06-11T11:28:54Z Indexed on 2010/06/11 11:32 UTC
Read the original article Hit count: 224

Filed under:

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.

© Stack Overflow or respective owner

Related posts about asp.net-mvc