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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:10:55+00:00 2026-05-23T02:10:55+00:00

Here ans Scenario: I have setup couple of ViewModels like: public class ThreadEditorView {

  • 0

Here ans Scenario:
I have setup couple of ViewModels like:

public class ThreadEditorView
{
    public int ForumID { get; set; }
    public ThreadEditorPartialView ThreadEditor { get; set; }
    public ThreadEditorSpecial ThreadSpecial { get; set; }
}

Now I have and View:

@using (Html.BeginForm("NewThread", "Thread", FormMethod.Post, 
    new {@enctype="multipart/form-data"})) {

    @Html.ValidationSummary(true)
    <fieldset>
        @Html.Partial("_ThreadEditor", Model.ThreadEditor)
        @Html.Partial("_SpecialProperties", Model.ThreadSpecial)
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

Question is how do I pass data from partial views into controller ?
I know I can simply do this:

public ActionResult NewThread(ThreadEditorView modelEditor, 
    ThreadEditorPartialView blabla, ThreadEditorSpecial zumg)

But that doesn’t look really convenient, I’d like to pass everything in ThreadEditorView.

Update:
SpecialView

@model Vaniv.Core.ViewModel.Forums.ThreadEditorSpecial

        <div class="editor-label">
            @Html.LabelFor(model => model.IsSticky)
        </div>
        <div class="editor-field">
            @Html.RadioButtonFor(model => model.IsSticky, false)
            @Html.ValidationMessageFor(model => model.IsSticky)
        </div>
(some irrevalnt forms)
        <div class="editor-field">
            @Html.EditorFor(model => model.IsLocked)
            @Html.ValidationMessageFor(model => model.IsLocked)
        </div>

And Editor:

@model Vaniv.Core.ViewModel.Forums.ThreadEditorPartialView


    <legend>ThreadEditorPartialView</legend>
    @Html.HiddenFor(model => model.ForumID)
    <div class="editor-label">
        @Html.LabelFor(model => model.ThreadName)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.ThreadName)
        @Html.ValidationMessageFor(model => model.ThreadName)
    </div>

(some forms, that are irrevelant)

    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Message)
    </div>
    <div class="editor-field">
        @Html.TextAreaFor(model => model.Message)
        @Html.ValidationMessageFor(model => model.Message)
    </div>
  • 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-23T02:10:56+00:00Added an answer on May 23, 2026 at 2:10 am

    I would recommend you using editor templates instead of partials as they will take care of generating proper names for your input fields so that the model binder is able to correctly resolve the values in the POST action:

    @using (Html.BeginForm("NewThread", "Thread", FormMethod.Post, 
        new {@enctype="multipart/form-data"})) {
    
        @Html.ValidationSummary(true)
        <fieldset>
            @Html.EditorFor(x => x.ThreadEditor)
            @Html.EditorFor(x => x.ThreadSpecial)
            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>
    }
    

    and have the corresponding editor templates (note that the names and location of the editor templates are important):

    ~/Views/Shared/EditorTemplates/ThreadEditorPartialView.cshtml:

    @model ThreadEditorPartialView
    <legend>ThreadEditorPartialView</legend>
    @Html.HiddenFor(model => model.ForumID)
    <div class="editor-label">
        @Html.LabelFor(model => model.ThreadName)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.ThreadName)
        @Html.ValidationMessageFor(model => model.ThreadName)
    </div>
    

    and ~/Views/Shared/EditorTemplates/ThreadEditorSpecial.cshtml:

    @model ThreadEditorSpecial
    ...
    

    Now your controller action could simply look like this:

    public ActionResult NewThread(ThreadEditorView modelEditor) 
    { 
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code snippet: class Test { public int Length{ get; set; }
Here's my scenario - I have an SSIS job that depends on another prior
I have a page here prompt get an input and stores in a variable
I have created android application that uses Google Maps, ans it works fine here
Here's my code: namespace RequestApi { public partial class MainPage : PhoneApplicationPage { private
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
Here we go again, the old argument still arises... Would we better have a

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.