c# - Difference between ValidationMessage and ValidationMessageFor -


for validation purpose using validationmessage , validationmessagefor helpers. both displaying error messages , major difference between validate message , validation message for. searched in various web sites can't find answer. appreciated.

code:

 @html.validationmessage("firstname", "main error", new {style="color:gray;" })  @html.validationmessagefor(x => x.firstname,"",new {@style="color:green;" }) 

there no difference.. except validationmessagefor indeed strongly typed... whereas validationmessage stringly typed (read: weakly typed).

the second 1 gives added benefit of being caught error.. before runtime.

you appear have different styles on them.. difference :)


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -