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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:46:17+00:00 2026-06-15T21:46:17+00:00

I am working on mvc – 3. I have created a register model and

  • 0

I am working on mvc – 3. I have created a register model and a register view.

Register view :

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true, "Correct the errors and try again.")
    <div>
        <fieldset>
            <legend>Account Information</legend>
            <div class="editor-label">
                @Html.LabelFor(m => m.UserName)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.UserName)
                @Html.ValidationMessageFor(m => m.UserName)
            </div>
            <div class="editor-label">
                @Html.LabelFor(m => m.Email)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Email)
                @Html.ValidationMessageFor(m => m.Email)
            </div>
            <div class="editor-label">
                @Html.LabelFor(m => m.Password)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.Password)
                @Html.ValidationMessageFor(m => m.Password)
            </div>
            <div class="editor-label">
                @Html.LabelFor(m => m.ConfirmPassword)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.ConfirmPassword)
                @Html.ValidationMessageFor(m => m.ConfirmPassword)
            </div>
            <div class="editor-label">
                @Html.LabelFor(m => m.Question)
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(m => m.Question, new SelectList(Model.Questions))   
                @Html.HiddenFor(m => m.Questions)             
            </div> 
            <div class="editor-label">
                @Html.LabelFor(m => m.Answer)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Answer)
                @Html.ValidationMessageFor(m => m.Answer)
            </div>
            <p>
                <input type="submit" value="Register" />
            </p>
        </fieldset>
    </div>
}

Register Model

public class RegisterModel
{
    [Required]
    [Display(Name = "User name")]
    public string UserName { get; set; }

    [Required]
    [RegularExpression(@"^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$", ErrorMessage="Invalid email address")]
    [DataType(DataType.EmailAddress)]
    [Display(Name = "Email address")]
    public string Email { get; set; }

    [Required]
    [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }

    [DataType(DataType.Password)]
    [Display(Name = "Confirm password")]
    [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
    public string ConfirmPassword { get; set; }

    [Display(Name = "Security question")]
    public string Question { get; set; }

    [Display(Name = "Security question")]
    public List<string> Questions { get; set; }

    [Display(Name = "Security answer")]
    public string Answer { get; set; }
}

My issue is when we submit the register form to server than all data will send to server except questions list. So if validation fails than i am getting the exception Model.Questions is null. How can i solve this issue ?

  • 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-15T21:46:19+00:00Added an answer on June 15, 2026 at 9:46 pm

    Look at my example and you will understand how it works:

    @{
        List<string> test = new List<string> { "111", "222", "333" };
    }
    
    <div id="test1">
         @Html.HiddenFor(x => test)
    </div>
    
    <div id="test2">
        @for (int i = 0; i < test.Count; i++)
        {
            @Html.HiddenFor(x => test[i])
        }
    </div>
    

    Will render:

    <div id="test1">
        <input id="test" name="test" type="hidden" value="System.Collections.Generic.List`1[System.String]" />
    </div>
    
    <div id="test2">
        <input id="test_0_" name="test[0]" type="hidden" value="111" />
        <input id="test_1_" name="test[1]" type="hidden" value="222" />
        <input id="test_2_" name="test[2]" type="hidden" value="333" />
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an MVC site using NHaml for the view engine. I
I'm working on a MVC application in which the Model is implemented using an
I'm working on MVC project and i using jQuery in view page to get
I'm working with MVC, I have a view with an ActionLink that calls an
I'm working with MVC in .net 4.0. I have a basic Html.ActionLink and I
I have a working MVC 4 edit view that edits a stored database record.
I'm working on MVC 3 application, I have managed to create a dynamically created
I am working on an MVC application and I have an index view where
I have a working zend mvc application that is using a layout, and this
I am working on MVC and in the model I created a class that

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.