urlreader urlreader - 2 months ago 13
ASP.NET (C#) Question

asp.net mvc Redirect to action without triggering validation in current view?

I have a view which has multiple submit buttons. One button is for going back to another action which does some processing and load previous view.

However, in current view, it has some validations for model. So, when the button is click, it will show validation error.

Is there a way to get around this? or, we have to validate the data on server side?



The built in client side validation in ASP.NET MVC uses the jquery validation plugin under the hood where you can skip validation while still using a submit-button with adding class="cancel" to that input:

<input type="submit" value="Do not validate" class="cancel" />

See this also in the documentation.