View: You could name Options and Selected Option ID a bit better to clarify their usage depending on your implementation.
With this implementation you would (and should) populate the options list from your controller.
If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue.
The selected option would be populated when the user selects an option.
Like this: Controller: As a side note, I would recommend naming your Validation Model after what the view that uses it is doing (e.g.
Then the click event will cause the page being refreshed, so it looks like that the validation doesn't work.
If we set the button 'type="submit"', when we click the button, it will automatically submit the form.
Please bear in mind that I am new to MVC so correct me if I my approach is wrong for implementing validation.
I created model class like this : Here what I want is when my drop-down list is in Select Mode that is default, it should show please select at least one option error and if user selects 1st or 2nd option then this error message should not display.
I'm guessing you will have two of these validators, because you have two Drop Down Lists.
The Required Field Validator can evaluate a Drop Down List by assigning its Initial Value property to the value associated with "Pending".
It generates client-side validation code which works on many more browsers than ASP. You would create the necessary "evaluation function" both on the client and server side that evaluates the textbox and if not blank, checks the selected item on the Drop Down List. First I added a requiredfield Validator to each DDL and set the inital Value to the value of the DDL selection that you are checking for. Visible to False I then wrote the following and called it in the textbox Change event...