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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:14:01+00:00 2026-05-23T15:14:01+00:00

I have a ASP.NET MVC 3 view with esentially two forms, but which reside

  • 0

I have a ASP.NET MVC 3 view with esentially two forms, but which reside in the same form tag.
Not sure if this is the correct way to approach this, so please suggest if theres a better solution.

The user have two options on this single page. It’s about subscribing to a newsletter, and if the user already has a subscription number, only one of the “forms” are required to be validated.
If the user does not have a subscription number, the other form is required to be validated.
I’m aware that this could be developed much more user friendly (and programmer), but it’s a requirement from the customer.

My problem is, when submitting the form, all of the fields are of course validated. Somewhere I need to provide a check to see if the user has filled out the SubscriptionNumber field, and then control what “form” to validate.
Do you have any suggestions on how to do that? I would of course like to keep this as simple as possible.

Here’s my view Subscribe:

@model SubscribeNewsletterModel

@using (Html.BeginForm())
{    
    @Html.EditorFor(m => m.ExistingSubscriber)        
    @Html.EditorFor(m => m.NewSubscription)
    @Html.ValidationSummary()
    <input type="submit" />
}

My view model for this view, looks like this:

public class SubscribeNewsletterModel
{
    public SubscribeNewsletterModel(SubscriptionModel subscriptionModel,
        ExistingSubscriberModel existingSubscriberModel)
    {
        this.NewSubscription = subscriptionModel;
        this.ExistingSubscriber = existingSubscriberModel;
    }

    // The models contains validation logic (attributes like Required, etc.)

    public SubscriptionModel NewSubscription { get; set; }
    public ExistingSubscriberModel ExistingSubscriber { get; set; }
}

And my controller responsible for handling the POST request. This doesn’t do anything yet – just for validation:

[HttpPost]
public ActionResult Subscribe(
    [Bind(Prefix="NewSubscription")] SubscriptionModel newSubscriptionModel,
    [Bind(Prefix="ExistingSubscriber")] ExistingSubscriberModel existingSubscriberModel)
{
    var vm = new SubscribeNewsletterModel(newSubscriptionModel, existingSubscriberModel);    
    return View(vm);
}
  • 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-23T15:14:01+00:00Added an answer on May 23, 2026 at 3:14 pm

    Based on your condition: “It’s about subscribing to a newsletter, and if the user already has a subscription number, only one of the “forms” are required to be validated. If the user does not have a subscription number, the other form is required to be validated.”

    Create parameter in your view that will be send back to controller where you validate your form and use this parameter to determine what will be validated. You will have to work with

    ModelState
    

    You can remove properties that you dont want to be validated by key.

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

Sidebar

Related Questions

I have an ASP.NET MVC view which contains checkboxes for user-defined categories. <td><% foreach
I have a custom view engine in ASP.NET MVC and since upgrading to RC1
I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7
I have an ASP.NET MVC project with a form. In the Action method that
I have an asp.net mvc register view. This is the first page. If someone
In my ASP.Net MVC View, I have a menu. The menu consists of a
I have an ASP.Net MVC site, which connects to a web service. The site's
I have an asp.net mvc application with a route similar to: routes.MapRoute(Blog, {controller}/{action}/{year}/{month}/{day}/{friendlyName}, new
I have an ASP.NET MVC (Beta 1) website that I'm using themes with. When
I have an ASP.NET MVC application, when a user clicks on the submit button

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.