Monday, 20 June 2011

Insert value to database in mvc2 pattern

I am continuing the above samples.Before see this post kindly make a note on above that it will be easy for you to understand.

Here i had written code in model.Its developer wish to write the code in controller or separate class file.

In Controller


Here Test is class name which is in model.Also in model we create one method name test.In controller we just getting value and pass it to the method and inserting value to database.

In views nothing is changed.

for your reference just posting that also(as same as above samples).

And the output is:

Friday, 17 June 2011

Client Side Validation in mvc

There ate two types validation in mvc :Client side and Server side.Client side is more faster than server side validation.Its detect the error when we pressed tab button.Also its wont load the page until solve the validation error.Lets see the ex:

Add the Above three Line in view page.just we need to enable client validation in this will take care of remaining things.Also we need to write some code in model.
In Model:


Just add the two componentModel and DataAnnotations in header. In the above property declare which type validation you required.
The Output is: