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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:18:23+00:00 2026-06-14T21:18:23+00:00

I am currently designing a web application using mvc 3 and c#. I have

  • 0

I am currently designing a web application using mvc 3 and c#. I have to do the following scenario and am trying to determine what the correct implementation would be for the platform. Here we go, I have to show/hide several form elements(textboxes) depending upon the selection of a dropdown list, which should also be a part of the form. What would be the best way to implement this under the mvc 3 platform. One major issue I have is that all of the elements that should appear, should also be required as well and the others should not be required. I would prefer to use DataAnnotation validation. Should I initially render all of the form elements and use javascript to determine which ones to show/hide based upon dropdown selection? The issue here seems to be how do I vary the required logic while maintaining the validation logic that makes sure that if anything is entered in any field, it is validated? On the other hand, it seems like overkill to create a partial view for each form that is needed and show/hide the partial view based upon dropdown selection, not to mention inefficient due to the rountdrips.

  • 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-14T21:18:24+00:00Added an answer on June 14, 2026 at 9:18 pm

    Perhaps you could do this on the front end with jQuery. Eg

    <select name="source" id="source">
      <option value="null" selected="selected">&mdash;Select&mdash;</option>
      <option value="o1">Option 1</option>
      <option value="o2">Option 2</option>
      <option value="o3">Option 3</option>
    </select>
    
    <div id="content"> some content to show/hide </div>
    

    And the corresponding jquery:

    $('#source').change(function() {
        ($(this).val() == "o3") ? $('#content').show() : $('#content').hide();
    });
    

    So basically when some selects option 3, the div content will displayed. I am not sure why you would need to use ajax, but you can just validate the values on the server side once the data has been submitted.

    Also might be beneficial to look at conditional validations using the Mvc.ValidationToolkit:

    • http://andrewtwest.com/2011/01/10/conditional-validation-with-data-annotations-in-asp-net-mvc/
    • http://blogs.msdn.com/b/simonince/archive/2011/09/29/mvc-validationtookit-alpha-release-conditional-validation-with-mvc-3.aspx
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently designing a web application using php, javascript, and MySQL. I'm considering two
I am designing a web application using GWT currently, which is also the first
I am currently designing a web application where I will have customers signing up
I currently have a Web Application which is using it's own Permissions table which
I'm currently designing a web application using DDD methodology. While distinguishing the Entities from
I am creating a new web service for an application and am currently designing
I'm currently designing an architecture for a web-based application that should also provide some
I'm currently designing a web application which may be viewed by people in all
I am designing a simple application using c# and it has a web browser
I am currently designing a web application that will allow users to schedule tasks

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.