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

  • Home
  • SEARCH
  • 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 8948569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:01:36+00:00 2026-06-15T13:01:36+00:00

I have this setup on my page roughly – a file upload control, and

  • 0

I have this setup on my page roughly – a file upload control, and a div (#changingBit) that swaps in different partial views with “List” being the default.

            <td><input type="file" name="Image" /></td>
            <td><input type="submit" value="Save" /></td>

                <div id="changingBit">
                    @Html.Partial("List", Model.Things)    
                </div>

These partial views basically list folders and files. I need to be able to pass a param ( like current Folder path ) which is available inside the actions for the partial views, to the upload controller action.

I tried adding this in the List / Edit Partial views

ViewData["id"] = some value...

But this is always null inside the main page. How do I grab that value inside the upload controller action?

Thanks!

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Upload(HttpPostedFileBase image)
    {

       //some magic to access a partial views variable
       // .............
       //

        if (image != null)
        {
            var fileName = Path.GetFileName(image.FileName);
            var path = Path.Combine(Server.MapPath("~/Directories/YourDirectory"), fileName);
            image.SaveAs(path);
        }
        return RedirectToAction("Index");
    }
    [HttpGet]
    public ActionResult Edit(int id)
    {
         ViewData["id"] = id;                 <--- how to get this file inside Upload action?
         ...

    }

Edit:

Ended up doing this on the main page

<input type="hidden" name="currentIdSelection" value="@Model.CurrentIdSelection" />

which works for now, I changed the model I passed into the “Edit” partial view to store another value. There’s probably a more MVC way to do this tho…

  • 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-15T13:01:37+00:00Added an answer on June 15, 2026 at 1:01 pm

    As a note, ViewData only lives in a single request.
    If you want to pass information around like what you are doing right now you can use TempData.

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

Sidebar

Related Questions

I have a page that is setup like this public partial class _Default :
On my portfolio page I have this setup: <div id=portfolio> <ul id=sites> <li> <h3><a
Good day to all. I have this setup: One page with text/whatever, that also
I have my asp.net sub-master page setup like this: <asp:Content ID=MainContent runat=server ContentPlaceHolderID=mainContent> <!doctype
I have this following setup, a textarea named with some data in it that
I have this kind of setup : Overridden BaseRunserverCommand that adds another option (--token)
I have this nice little MSBuild-based daily build setup that I use on my
On an Aspx page, I have this markup (setup for a jQuery UI dialog):
I have this routing setup at the moment routes.MapRoute( OldPages, // Route name page{id}.html,
I currently have a page setup like this: PHP Variable Declarations HTML header, then

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.