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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:26:20+00:00 2026-06-04T22:26:20+00:00

I have a PartialView that is an image upload, and basically I am displaying

  • 0

I have a PartialView that is an image upload, and basically I am displaying some images and then the normal Upload buttons :-

@model MvcCommons.ViewModels.ImageModel

<table>
    @if (Model != null)
    {
        foreach (var item in Model)
        {
            <tr>
                <td>
                    <img src= "@Url.Content("/Uploads/" + item.FileName)" />
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Description)
                </td>
            </tr>    
        }
    }

</table>

@using (Html.BeginForm("Save", "File", FormMethod.Post, new { enctype = "multipart/form-data" })) {
    <input type="file" name="file" />
    <input type="submit" value="submit" /> <br />
    <input type="text" name="description" /> 
}

Now my idea is to have this in different pages. I tried it in 1 page already and is working fine, however when I Upload an image,

public ActionResult ImageUpload()
{
    ImageModel model = new ImageModel();
    model.Populate();
    return View(model);
}

I want to go back to the “previous” View, ie the View that is hosting this partial view? When I do return View(model) as above, I get into the ImageUpload partial view which I do not want to.

Thanks for your help and time.

***UPDATE*********
I went for the simple route for the time being, and hard coded the actual View name

public ActionResult ImageUpload()
{
    ImageModel model = new ImageModel(); 
    model.Populate(); 
    return View("~/Views/Project/Create.cshtml", model); 
}

however I got an error :-

The model item passed into the dictionary is of type MvcCommons.ViewModels.ImageModel, but this dictionary requires a model item of type MvcCommons.Models.Project.

  • 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-04T22:26:22+00:00Added an answer on June 4, 2026 at 10:26 pm

    Use the overload that takes a string of the name of the view you want.

    http://msdn.microsoft.com/en-us/library/dd460310

    protected internal ViewResult View(
            string viewName,
            Object model
    )
    

    i.e.

    return View("ViewName", model);
    

    if you have this in different pages then you can inject context via the action paramaters;

    public ActionResult ImageUpload(string parentViewName)
    {
        ImageModel model = new ImageModel();
        model.Populate();
        return View(parentViewName, model);
    }
    

    NOTE: You should only need to pass the views name not the path:

    return View("Create", model);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a partial view that I want to basically take care of itself
I have a problem with an image that I am applying a custom jquery
I have a view that displays multiple images and those images' associated tags. I
I have a paging menu PartialView in my MVC app that looks like: <%
I have dialog tha contains a partialview. Is it possible to undo changes that
I have a model that looks like this: public class Book { public string
I have a model that contains an IEnumerable of a list of custom objects.
I have some code in a controller (HomeController.cs) that gets called from a $.get
I have a viewpage and a partialview on that. For default request-when page is
I have a PartialView, on a form that does an ajax post. All my

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.