Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

asp.net mvc - Multiple validations on a property using FluentValidation -


i'm using fluentvalidation , asp.net mvc 3.

i have couple of questions regarding validation.

i have validation on view model setup this:

public newsviewmodelvalidator() {    // title required    rulefor(x => x.title)       .notempty()       .withmessage("title required");     // title must less or equal 100 characters    rulefor(x => x.title)       .length(1, 100)       .withmessage("title must less or equal 100 characters"); } 

is how must done, or need include in 1 statement?

i need 2 validations done on title property, name must required field , cannot longer 100 characters. below source after validation triggered:

<td valign="top"><b>title: *</b></td> <td>    <input class="input-validation-error" data-val="true" data-val-length="title must less or equal 100 characters" data-val-length-max="100" data-val-length-min="1" data-val-required="title required" id="title" max="100" name="title" size="100" type="text" value="" /><br>    <span class="field-validation-error" data-valmsg-for="title" data-valmsg-replace="true">title required</span> </td> 

it's using 2 different classes, 1 each validation type. why this? form not consistent. have input field required, , class used input-validation-error, above field-validation-error.

how enable client-side validation? told if have following code set in web.config client side automatically turned on:

<appsettings>    <add key="clientvalidationenabled" value="true"/>    <add key="unobtrusivejavascriptenabled" value="true"/> </appsettings> 

client-side validation not triggered. need include jquery library or done me?

you need add these _layout.cshtml :

<script src="/scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script src="/scripts/jquery.validate.min.js" type="text/javascript"></script> <script src="/scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script> 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -