Showing posts with label ASP.NET MVC. Show all posts
Showing posts with label ASP.NET MVC. Show all posts

Extending EntLib VAB - Part 2.2: Enable unobtrusive jQuery validation for Custom Validator

3 comments


Note: Thank you for visiting my blog. However, this blog is not maintained actively anymore. This post is now also in my new blog. Feel free to leave a comment there.

… Continuation from Extending EntLib VAB - Part 2.1: Create custom validators and integrate that with EntLib CABC.

Now lets see how we can enable client side unobtrusive validation for this custom validator by creating adapter for the same and adding the adapter in our custom implementation of DataAnnotationsModelValidatorProvider  (explained in Extending EntLib VAB - Part 1: Enable client side support EntLib VAB and align the validation error keys with MVC ModelState keys) and finally writing unobtrusive jQuery validation.

Extending EntLib VAB - Part 2.1: Create custom validators and integrate that with EntLib CABC

0 comments


Note: Thank you for visiting my blog. However, this blog is not maintained actively anymore. This post is now also in my new blog. Feel free to leave a comment there.

Here is the second last installment post of this series. If you are interested in checking the earlier posts here are the links: Extending Enterprise Library (EntLib) Validation Application Block (VAB) – Introduction, Extending EntLib VAB - Part 1: Enable client side support EntLib VAB and align the validation error keys with MVC ModelState keys (I strongly suggest to check at least part 1 of this series as we are going to reuse here a component that we have developed in that post).

In this post we will see how to develop a custom validator for EntLib VAB. If you are developing a custom validator, there are several aspects you have to take care for: Obviously the first and foremost is write your actual validator that works on server side and integrate that with CABC, next is to enable client side validation for your validator (now when we are talking about client side validation, in ASP.NET MVC it is important to write the client side validation in jQuery unobtrusive validation to provide your end user similar kind of experience as they have with other Out-Of-The-Box validators) and lastly as you are working with EntLib provide support so that your custom validator also seamlessly integrates with EntLib Configuration Application Block Console (CABC). In this post we are going to cover all of these.

ASP.NET MVC: ActionNameSelector and ActionMethodSelector (or another approach to submit form to multiple action methods) – Part II

0 comments


Note: Thank you for visiting my blog. However, this blog is not maintained actively anymore. This post is now also in my new blog. Feel free to leave a comment there.

Hope you enjoyed the first part of this blog post.

In this part I’ll discuss about how you can make your own ActionMethodSelector Attribute (though I'll use the out-of-the-box ActionNameSelectorAttribute ActionNameAttribute).

Lets first discuss the problem statement: I’ve one form which has two radio buttons and I want the form to be posted to two different Action Methods based on selection.

ASP.NET MVC: ActionNameSelector and ActionMethodSelector (or another approach to submit form to multiple action methods) – Part I

0 comments

Note: Thank you for visiting my blog. However, this blog is not maintained actively anymore. This post is now also in my new blog. Feel free to leave a comment there.

At work I have recently faced a requirement to post a single form to multiple Action methods in a controller based on the context. For example, in the view there is a Form and there are several radio buttons; now my form should be posted to the Action method based on the radio button selection.
As usual I Googled it and found that internet is glutted with various approaches. Some of them are: 1. Posting to single action method and use a switch mechanism inside it, 2. Using multiple forms, 3. Using named submit button and assigning different values to those.
However there is one concept that I liked most and that is making use of ActionNameSelector and ActionMethodSelector.

What are these?
Well these are attributes that influence/affects the selection of action methods… yes you got it right. I’ve quoted it from MSDN and just like some of you (maybe) I didn't understood a thing when I read those lines... ;)
You can check the below MSDN links:
ActionNameSelectorAttribute Class, ActionMethodSelectorAttribute Class.
Hmmm… so what are these anyway.