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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:07:25+00:00 2026-05-22T13:07:25+00:00

I am Using MVC 3.0 My issue is on one page I am using

  • 0

I am Using MVC 3.0

My issue is on one page I am using same model twice with some validation. But client side validation are gets applied for first model only.

My code in view is

 @using (Html.BeginDTPanel("Applicant"))
        {
         <text>
            @Html.Partial("~/areas/common/views/shared/_customer.cshtml", Model.Applicant)
         </text>    
        }

        @{ var state = Model.Mode == ActionMode.Edit && Model.CoApplicant.TaxIdentifierLastFour != null ? "expanded" : "collapsed"; }
        @using (Html.BeginDTPanel("Co-applicant", state))
        {
         <text>
            @Html.Partial("~/areas/common/views/shared/_customer.cshtml", Model.CoApplicant)
         </text>    
        }

_Customer.cshtml code is something like

@Html.LabelFor(Model.Prefix, m => m.FirstName, "First Name")

@Html.TextBoxFor(Model.Prefix, m => m.FirstName)
@Html.ValidationMessageFor(Model.Prefix, m => m.FirstName)

@Html.LabelFor(Model.Prefix, m => m.MiddleName, “Middle Initial”)
@Html.TextBoxFor(Model.Prefix, m => m.MiddleName)
@Html.ValidationMessageFor(Model.Prefix, m => m.MiddleName)

@Html.LabelFor(Model.Prefix, m => m.LastName, “Last Name”)
@Html.TextBoxFor(Model.Prefix, m => m.LastName)
@Html.ValidationMessageFor(Model.Prefix, m => m.LastName)

Validation model which I used is as below

[RequiredIf(ErrorMessage=”Please Enter First Name”)]
[StringLength(15, ErrorMessage = “Maximum character limit exceeded”)]
[RegularExpression(@”^[a-zA-Z0-9 ]+(([\’\,.-][a-zA-Z0-9 ])?[a-zA-Z0-9 ])$”, ErrorMessage = “Incorrect First Name”)]
public string FirstName { get; set; }

    [StringLength(1, ErrorMessage = "Maximum character limit exceeded")]
    [RegularExpression(@"^[a-zA-Z ]$", ErrorMessage = "Incorrect Middle Initial")]
    public string MiddleName { get; set; }

    [RequiredIf(ErrorMessage = "Please Enter Last Name")]
    [StringLength(25, ErrorMessage = "Maximum character limit exceeded")]
    [RegularExpression(@"^[a-zA-Z0-9 ]+(([\'\,\.\-][a-zA-Z0-9 ])?[a-zA-Z0-9 ]*)*$", ErrorMessage = "Incorrect Last Name")]
    public string LastName { get; set; }

    [RequiredIf(ErrorMessage = "Please Enter SSN")]
    [StringLength(11, ErrorMessage = "Maximum character limit exceeded")]
    [SouciaSecurityNumber(ErrorMessage ="Invalid SSN")]
    [RegularExpression(@"^([0-9]\d{2}|7[0-6]\d|77[0-2])([ \-]?)(\d{2})\2(\d{4})$", ErrorMessage = "InValid SSN")]
    public string TaxIdentifier { get; set; }

The exact issues is here I am using same model with validation for both applicant and coapplicant. but when page render validation actully applies to first Applicant only.

When I checked view source
validation related code rendered for Applicant only.

But I need to apply validation for both the mode.

Please suggest any solution you have.

Thanks

  • 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-22T13:07:26+00:00Added an answer on May 22, 2026 at 1:07 pm

    A did add follwing line to my .cshtml file its working now.

    @{ ViewData.TemplateInfo = new System.Web.Mvc.TemplateInfo { HtmlFieldPrefix = Model.Prefix }; }

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

Sidebar

Related Questions

I'm using ASP.NET MVC 2 and here's the issue. My View Model looks something
I'm using MVC to validate some html text boxes on a page, for example
Have you tried using MVC or any other UI pattern for GWT client code.
I'm using MVC, I've got a search page, and I want to pass multiple
I am facing this bizarre problem in my asp.net mvc application: In one page
I have a strange issue with an Asp.NET MVC application. Using Asp.NET MVC 3
We have a strange issue with running an Facebook IFrame application (using MVC 2).
I'm using the Obout.com MVC controls and have included the following code in one
I am using Visual Studio 2010 and MVC 3 with AJAX/JQuery. The issue I
Framework: I'm using using MVC 3 + EntityFramework 4.1 Code-First. Concept: One Legislation entity

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.