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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:44:43+00:00 2026-06-12T14:44:43+00:00

This has me completely stumped so I figured I would ask around and see

  • 0

This has me completely stumped so I figured I would ask around and see if there is a solution to this!

I have a ticketing system that I am currently working on and one of the fields is “Primary Contact” — Code below;

<tr>
    <td>
        @Html.Label("Client Contact:")
    </td>
    <td>
        @Html.TextBoxFor(model => model.PrimaryContact, new { placeholder = "Primary contact for this ticket." })
        <br />
        @Html.ValidationMessageFor(model => model.PrimaryContact)
    </td>
</tr>

I had a user request a feature; the ability to have say a “+” button where they can click and it adds another field (I will accomplish this through javascript.) However, I need the fields that are created by the javascript to be bound to Model.PrimaryContact.. So essentially when the user adds another textbox for another contact it will then make the value of “Model.PrimaryContact” say something like the following:

Billy Joe 918-555-5556,Bobby Jane 876-222-3334

Then when this gets posted to the controller I can simply insert that into the database.

I am not too sure how this would be accomplished however I believe I’ll need some sort of custom model binder that is comma delimited?

Any help would be greatly appreciated!

  • 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-12T14:44:44+00:00Added an answer on June 12, 2026 at 2:44 pm

    Change “model.PrimaryContacts” to the list of strings List<string> and render:

        <input type="text" id="PrimaryContacts[0]" name="PrimaryContacts[0]" value="" />
        <input type="text" id="PrimaryContacts[1]" name="PrimaryContacts[1]" value="" />
        <input type="text" id="PrimaryContacts[2]" name="PrimaryContacts[2]" value="" />
        <input type="text" id="PrimaryContacts[3]" name="PrimaryContacts[3]" value="" />
    

    It’s important that “name” attribute is same on each field (id doesn’t matter), and they will automatically bind into array or collection.

    Update:

    if we assume that PrimaryContact is object with FirstName, LastName and PhoneNumber properties, then we would need to render following markup on the page:

        <!-- 1st person -->
        <input type="text" id="[0].FirstName" name="[0].FirstName" value="" />
        <input type="text" id="[0].LastName" name="[0].LastName" value="" />
        <input type="text" id="[0].PhoneNumber" name="[0].PhoneNumber" value="" />
        <!-- 2nd person -->
        <input type="text" id="[1].FirstName" name="[1].FirstName" value="" />
        <input type="text" id="[1].LastName" name="[1].LastName" value="" />
        <input type="text" id="[1].PhoneNumber" name="[1].PhoneNumber" value="" />
    

    Above would bind to List<PrimaryContact> objects.

    Update 2:

    Last but not least, to bind to the Dictionary<string, PrimaryContact> you do this:

    <!-- 1st person -->
    <input type="hidden" id="[0].Key" name="[0].Key" value="1stPersonKey" />
    <input type="text" id="[0].FirstName" name="[0].Value.FirstName" value="" />
    <input type="text" id="[0].LastName" name="[0].Value.LastName" value="" />
    <input type="text" id="[0].PhoneNumber" name="[0].Value.PhoneNumber" value="" />
    <!-- 2nd person -->
    <input type="hidden" id="[1].Key" name="[1].Key" value="2ndPersonKey" />
    <input type="text" id="[1].FirstName" name="[1].Value.FirstName" value="" />
    <input type="text" id="[1].LastName" name="[1].Value.LastName" value="" />
    <input type="text" id="[1].PhoneNumber" name="[1].Value.PhoneNumber" value="" />
    

    Hope this helps a bit

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

Sidebar

Related Questions

Ok, so this has me completely stumped just like the guy here with the
Regex is absolutely my weak point and this one has me completely stumped. I
This portion of my current assignment has me completely stumped: I am trying to
I have to admit I am COMPLETELY stumped on this one. I've been scouring
I am completely stumped. I have a program that pulls information stored in a
This one has completely stumped me. I tweaked my css so regular bootstrap modals
This has got me completely stumped: print_r($json); echo json_encode($json); output: Array ( [query] =>
This problem has completely stumped me. This is for iOS 5.0 with Xcode 4.2
I am completely stumped on something that I thought would be the easiest thing
This has defeated me. I want to have a static class variable which is

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.