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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:10:18+00:00 2026-06-07T10:10:18+00:00

i created ViewModel to test this answer : How to fill ViewModel which has

  • 0

i created ViewModel to test this answer : How to fill ViewModel which has List<T> property after clicking submit button mvc 3?

i need checkboxlist look please WeeklyModel.Also WeeklyViewModel. i want to list alldoays in checkboxes. Nut my error below . it is stupid error. i can not understand reson to solve how to solve it? thanks…
Look please helpful ( what i need artcile) article : When do I use View Models, Partials, Templates and handle child bindings with MVC 3
Models:


   public class WeeklyModel

        {
            public string Name { get; set; }
            public string Value { get; set; }
            public bool IsChecked { get; set; }
        }


       public class WeeklyViewModel
        {
            public IEnumerable<WeeklyModel> Settings { get; set; }
            public WeeklyViewModel()
            {
                Settings = new List<WeeklyModel>();
            }

        }

Controller:


 public ActionResult CreateWeekly()
       {
           var model = new WeeklyViewModel();
            List<WeeklyModel> li = new List<WeeklyModel>();
            li.Add( new WeeklyModel(){ Name="Monday", Value="mon", IsChecked=false});
            model.Settings = li;
               return View(model);
       }
       [HttpPost]
        public ActionResult CreateWeekly( WeeklyViewModel weekly)
       {

           return View("CreateWeekly", weekly);
       }

i created Views/Trigger/EditorTemplates/WeeklyModels.aspx :


<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ChildSite.Master" Inherits="System.Web.Mvc.ViewPage<GenSystem.Models.WeeklyModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%:Html.CheckBoxFor(m=>m.IsChecked) %>
<%:Html.LabelFor(m=>m.IsChecked,Model.Name) %>
<%:Html.HiddenFor(m=>m.Name) %>
<%:Html.HiddenFor(m=>m.Value) %>

</asp:Content>

View :


<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ChildSite.Master" Inherits="System.Web.Mvc.ViewPage<GenSystem.Models.WeeklyViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    CreateWeekly
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<% 

    using (Html.BeginForm())
    {
          %>

      <div>
     <%:Html.EditorFor(m => m.Settings)%>
      </div>
    <br />
       <input value="GenerateForWeekly" name="submitButton" type="submit" />
          <%} %>
</asp:Content>

   

How to solve this Error:

System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary
2.Add(TKey key, TValue value)
at Transformer.NET.Token.ParseAnchors()
at Transformer.NET.TextTransformer.Parse(List1 tokensType, Dictionary2 variables)
at Transformer.NET.TextTransformer.Transform(List1 tokensType, Dictionary2 variables)
at Transformer.NET.TextTransformer.Transform(List`1 tokensType)
at Transformer.NET.TextTransformer.Transform()
at Ext.Net.ExtNetTransformer.Transform(String text)
at Ext.Net.InitScriptFilter.Transform()
at Ext.Net.InitScriptFilter.Flush()
at System.Web.HttpWriter.Filter(Boolean finalFiltering)
at System.Web.HttpResponse.FilterOutput()
at System.Web.HttpApplication.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

  • 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-07T10:10:21+00:00Added an answer on June 7, 2026 at 10:10 am

    Editor templates should be .ascx controls, not .aspx pages. Also your file is wrongly named. It is named WeeklyModels.aspx but the correct name is WeeklyModel.ascx (without s) because your class is called WeeklyModel and not WeeklyModels.

    So inside ~/Views/Shared/EditorTemplates/WeeklyModel.ascx you could put the following:

    <%@ Control 
        Language="C#" 
        Inherits="System.Web.Mvc.ViewUserControl<GenSystem.Models.WeeklyModels>" 
    %>
    <%= Html.CheckBoxFor(m => m.IsChecked) %>
    <%= Html.LabelFor(m => m.IsChecked, Model.Name) %>
    <%= Html.HiddenFor(m => m.Name) %>
    <%= Html.HiddenFor(m => m.Value) %>
    

    and inside your main view CreateWeekly.aspx:

    <%@ Page 
        Title="" 
        Language="C#" 
        MasterPageFile="~/Views/Shared/ChildSite.Master" 
        Inherits="System.Web.Mvc.ViewPage<GenSystem.Models.WeeklyViewModel>" 
    %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
        CreateWeekly
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <% using (Html.BeginForm()) { %>
            <div>
                <%= Html.EditorFor(m => m.Settings) %>
            </div>
            <br />
            <input value="GenerateForWeekly" name="submitButton" type="submit" />
        <% } %>
    </asp:Content>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button created in my view. In the ViewModel, I wish to
I've created a unit test that tests interactions on my ViewModel class in a
This test is to check that I can return a ViewModel object by creating
I have this very simple test view <button data-bind=click: add>Add</button> <table data-bind=foreach: items> <tr>
I've created a property IsLoading for my main view model. The idea is that
Created an OpenGraph action and object. Trying to submit my action. When I click
I'm trying to test a Presenter created using ASP.NET WebFormsMVP. I'm building it using
I'm having problems getting the new data from the RandomNumbers List I got this
I know this has been asked before but I can't find it so... Say
I'm playing around with MVC3, trying to create small test projects which simulate problems

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.