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 8477881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:35:24+00:00 2026-06-10T18:35:24+00:00

I am trying to pass values thought the submit button of a form. These

  • 0

I am trying to pass values thought the submit button of a form.

These are the values i need:

[HttpPost]
        public ActionResult Upload() //string token, string filename, string moddate, object file
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
                parameters.Add("Token", token);
                parameters.Add("FileName", filename);
                parameters.Add("ModDate", DateTime.Today.ToString());
                parameters.Add("File", file);

            String compleat = "Complete";  
            return View(compleat);              
        }

This is where i try get the values:

<form action="/Home/Upload" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
@string token = @Model.Token;
@string fileName = file.tostring();
@File actualfile = file;
<br>
<input type="submit" name="submit" value="Submit" />

I would like to do something like this, my JavaScript is probably wrong as i am new to it.

After the submit is clicked how can i access the variables from the home controller?

  • 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-10T18:35:25+00:00Added an answer on June 10, 2026 at 6:35 pm

    In MVC you want to work with viewmodels. There is also html.beginform helper to use so your code won’t look so messy.

    UploadViewModel.cs

    public class UploadViewModel
    {
        public string Token { get; set; }
        public string FileName { get; set; }
        public string ModDate { get; set; }
        public object File { get; set; }
    }
    

    HomeController.cs

        public ActionResult Upload()
        {
            TempData["Status"] = "";
            return View(new UploadViewModel());
        }
    
        [HttpPost]
        public ActionResult Upload(UploadViewModel upload) //string token, string filename, string moddate, object file
        {
            //*** Do something with the upload viewmodel
    
            // It's probably a good idea to store the message into tempdata
            TempData["Status"] = "Complete";
            return View();
        }
    

    Upload.cshtml

    @model UploadViewModel
    
    @Html.Label(TempData["Status"].ToString())
    @using (Html.BeginForm())
    {
        @Html.LabelFor(model => model.Token)
        @Html.EditorFor(model => model.Token)
        @Html.LabelFor(model => model.ModDate)
        @Html.EditorFor(model => model.ModDate)
        @Html.LabelFor(model => model.FileName)
        @Html.EditorFor(model => model.FileName)
        <input type="submit" name="submit" value="Submit" />
    }
    

    This is pretty basic stuff, you should read up some tutorials. Like these: http://www.asp.net/mvc/tutorials

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

Sidebar

Related Questions

I am trying to pass values from a ruby hash to a bash script..
i am trying to pass two values to php file via ajax my code
I'm an encryption novice trying to pass some values back and forth between systems.
I've got this JS highchart that I'm trying to pass some values into that
I am a little new to android/java. I am trying to pass JSON values
I am trying to pass a array that contains keys and values. The keys
I am trying to generate N random x values to pass to a charting
I have a web app with a form that I am trying to pass
I'm trying to pass multiple checkboxes with different values to a PHP script that
I am trying to pass multiple values for a single field name to an

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.