Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8384221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:21:13+00:00 2026-06-09T17:21:13+00:00

I have in my MVC view.. //Submit file <% using (Html.BeginForm(MethodName,ControllerName, FormMethod.Post, new {

  • 0

I have in my MVC view..

 //Submit file
 <% using (Html.BeginForm("MethodName","ControllerName", FormMethod.Post, new { enctype = "multipart/form-data"})) { %>         
     <input type="file" name="file" id="file"/>
     <input type="text" id="file-name" name="Id"/>
     <input type="submit" value="Submit" name="Submit"/>
 <% } %>     

//Save link.
 <span class="Update" onclick="js.function()">Update</span>

Once I click on the Submit button, I go to controller and the method to run some code that submits the file to the database. After that is finished, I need to auto-click/force click the save link so that the js function is run after the submit .. how can I do that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:21:14+00:00Added an answer on June 9, 2026 at 5:21 pm

    I would use Ajax.BeginForm and in the OnSuccess handler you can click the button. Your code would look something like this (not tested but should lead you in the right direction):

    <% using (Ajax.BeginForm("MethodName","ControllerName",
        new AjaxOptions { 
            OnSuccess ="OnSuccess",
            OnFailure ="OnFailure" 
        },  
        new { 
            enctype = "multipart/form-data"
        })) { %>         
         <input type="file" name="file" id="file"/>
         <input type="text" id="file-name" name="Id"/>
         <input type="submit" value="Submit" name="Submit"/>
     <% } %>    
    

    Javascript:

    function OnSuccess() {
        $('.Update').trigger('click');
    }
    

    Edit: If you were not trying to upload a file my above answer would be what you want. However, I have looked into this a little more as I noticed you were trying to post a file; and you cannot upload files using ajax without using html 5, iframe hacks, etc. It appears to me that your best bet would be to use an uploader such uploadify or plupload that resolve this issue using html5, flash, or hacks based on how you set them up.

    Also, binding-httppostedfilebase-using-ajax-beginform is a similar question that has something that may be of help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following form on an .NET MVC View: <form method=post enctype=multipart/form-data action=/Video/UploadDocument>
I have a form in my asp.net mvc view as follow: <%using (Html.BeginForm(SearchBorrowed, Admin,
i have the following code in an asp.net mvc view. <% = Html.DropDownList(Filter, new
If I have the below PartialView <%@ Control Language=C# Inherits=System.Web.Mvc.ViewUserControl<Models.Photo> %> <% using (Html.BeginForm(MyAction,
I have an MVC application view that is generating quite a large HTML table
I have a file upload button on my MVC view. After the file is
I am using ASP.NET MVC 3. I have an action method called New. When
I have an MVC view with a form built with the Ajax.BeginForm() helper method,
I have an ASP.NET MVC view that uses jquery.Uploadify to post files to one
Using Asp.net MVC, I have one view that's strongly bind to List , and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.