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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:58:58+00:00 2026-06-15T02:58:58+00:00

I created a partial view that should display a list of user with a

  • 0

I created a partial view that should display a list of user with a check box , so i can reuse this partial view in various pages.
The problem is that, i’m not able to have the correct htmlprefix the input generated
(I would like to remove the . of the prefix )

Model:

public class CircleEditViewModel
{
    [Key]
    public int CircleId { get; set; }

    [Required]
    [MaxLength(100)]
    public string Name { get; set; }

    public bool IsSystem { get; set; }

    public List<SimpleUserListViewModel> Users { get; set; }
    public CircleEditViewModel()
    {
        Users = new List<SimpleUserListViewModel>();
    }
}
public class SimpleUserListViewModel
{
    public SimpleUserListViewModel()
    {
    }
    public SimpleUserListViewModel(User user)
    {
        this.UserId = user.UserId;
        FullName = user.FullName;
    }
    public int UserId { get; set; }
    public byte[] Picture { get; set; }
    public string FullName { get; set; }
    public bool IsCheckedForAction { get; set; }
}

‘Main view’:

@model Wims.Website.ViewModels.CircleEditViewModel
<script type="text/javascript">
    $(document).ready(function () {

        $.validator.unobtrusive.parse('form');
    });
</script>

@using (Ajax.BeginForm(Html.ViewContext.RouteData.Values["Action"].ToString(), null, new AjaxOptions { HttpMethod = "POST", OnSuccess = "SaveDone(data)" }, new { id = "editform" }))
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Circle</legend>
        @Html.Label(DateTime.Now.ToString());
    <div class="editor-label">
        @Html.LabelFor(model => model.Name)
    </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>
    </fieldset>
    @Html.Partial("~/Views/Shared/_UserList.cshtml", Model.Users, 
        new ViewDataDictionary(Html.ViewDataContainer.ViewData)
            {
                TemplateInfo = new System.Web.Mvc.TemplateInfo { HtmlFieldPrefix = "Users" }
            })

   @Html.GenerateSecureDataControls(model => model.CircleId)
    <input type="submit" value="Save" />
}

Partial view:

@model List<Wims.Website.ViewModels.Shared.SimpleUserListViewModel>

@{  
    if (Model != null)
    {
        for (int i = 0; i < Model.Count; i++)
        {
    <div class="userDetail">
        <div>
            <div>
                @Html.CheckBoxFor(model => model[i].IsCheckedForAction)

            </div>
            <div class="iconDiv">
                @Html.Image("~/Content/Images/defaultUser.jpg", Model[i].FullName, null)
            </div>
            <div>
                @Html.TextBoxFor(model => model[i].FullName)
                @Html.HiddenFor(model => model[i].UserId)
            </div>
        </div>

    </div>
    <div style="clear: both"></div>
        }
    }
}

I am almost there, the input generated id’s are

id="Users.[0].FullName

Is there any way i can remove the first dot?
I’ve found some solution yesterday on a blog (which i can’t find anymore…) but it was for MVC3 and I couldn’t make it work anyway…

Thanks for the help!

EDIT:
Maybe I should use EditorFor instead of partial view:
.NET MVC 4 Strongly typed ViewModel containing Strongly typed Model with EditorFor and EditorTemplate partial view not binding
Will check tonight

  • 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-15T02:59:00+00:00Added an answer on June 15, 2026 at 2:59 am

    Alrighty, The EditorFor worked perfectly..
    I need to read more about this.

    • 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 have created called noteEditor. That is rendered
if i have created a view model and have a partial form that is
I created a partial view, abc in my Views/Home added this to my controller
I need to display a list of comments within a view. I have created
So right now I have a partial view that just has a list of
I have a partial view that loops through its Model (a list of things)
Entity Framework has created the required partial classes. I can add these partial classes
I have a partial view that inherits from ViewUserControl<Guid?> - i.e. it's model is
I’ve got the following code (from a partial view), which creates a list of
I've been doing some searches, found this ASP.NET MVC 3 - Partial vs Display

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.