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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:29:41+00:00 2026-05-26T05:29:41+00:00

I have a View that has the ability to both create and edit an

  • 0

I have a View that has the ability to both create and edit an item that I have separated into partial views:

MainEditView.cshtml
_CreateChildDialog.cshtml
_EditChildDialog.cshtml

I have separate ViewModels for both the Create and Child items:

public class CreateChildViewModel
{
    public string ItemText { get; set; }
}


public class EditChildViewModel 
{
    public string ItemText { get; set; }
}

Since the partial views for the Edit and Create dialog boxes will both be rendered on the same page, I will have a conflict for form id’s and names…since they are both called ItemText.

Is it possible to customize the binding of these elements without writing a custom model binder?

I would like to do something like:

public class EditChildViewModel
{
    [BindFrom("EditItemText")]
    public string ItemText { get; set; }
}

Or does it just make more sense to rename the ViewModel properties to:

public class EditChildViewModel 
{
    public string EditItemText { get; set; }
}

public class CreateChildViewModel
{
    public string CreateItemText { get; set; }
}

EDIT
Based on converstation with Darin I want to make this a little more clear.

My Parent has an Edit action.
When you edit the Parent, you would never create a new child or edit a child when you are calling the ParentController.Edit action.

I have a separate controller for the Child object that has a Create and Edit method:

public class ChildController 
{
    public ActionResult Edit() {}
    public ActionResult Create() {}
}

I am using jQuery calls to asynchronously post to this controller when you edit or create a child. Basically I use a jquery dialog to create/edit a child that will get saved immediately when I click Ok on the dialog. This would happen even before clicking save for the Edit action of the parent.

  • 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-05-26T05:29:41+00:00Added an answer on May 26, 2026 at 5:29 am

    I would use editor templates. Normally you would pack those two view models into a main view model which will be used by the main view:

    public class MyViewModel
    {
        public CreateChildViewModel Create { get; set; }
        public EditChildViewModel Edit { get; set; }
    }
    

    and then:

    @model MyViewModel
    @Html.EditorFor(x => x.Create)
    @Html.EditorFor(x => x.Edit)
    

    and I would replace the two partials by their corresponding editor templates (~/Views/Shared/EditorTemplates/CreateChildViewModel.cshtml and ~/Views/Shared/EditorTemplates/EditChildViewModel.cshtml). The editor templates will take of generating proper names and ids of the corresponding input elements.

    Personally I tend to prefer editor/display templates instead of partials as they handle better naming of input elements.

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

Sidebar

Related Questions

I'm using MVC2 with VS2010 I have a view that has two partial views
I have an app that has a centre view with two views off to
I have a view that has a list of jobs in it, with data
I have a picker view that has a list of numbers to pick from.
I have a view controller class that has to implement several protocols. Too keep
I have an iPhone app that shows a simple view (View 1) that has
I have a navigation view with a cell that has something as simple as
I have a plug-in to an Eclipse RCP application that has a view. After
I have a very simple Mac Cocoa app that just has a Web View
I have the problem that my view controller class has too many delegates 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.