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 - When `HttpGet` handling `Create` action method just returns `View()`, why doesn't the javascript validation get triggered on the browser? -


when httpget handling create action method returns view(), causes form fields uninitialized.

why javascript validation not triggered when users views blank form?

i don't know inner workings, i'll give guess ;-)

first of all, has nothing whether or not [httpget] or [httppost] -- that's way works.

your average [httpget] methods this:

[httpget] public actionresult index() {     // data database     return view(data); } 

there aren't parameters in method, because want user hit controller when type in url (i.e. home/index).

your usual [httppost] method might this:

[httppost] public actionresult create(mymodel mymodel) {     if (modelstate.isvalid)     {          // stuff     }     else     {         return view(mymodel);     } } 

i believe validation attributes aren't triggered until bind form values model , hit create(...) controller. if [httpget] happened take in model parameter, validation triggered @ point well.

when return view existing, invalid model, somehow validationmessagefor(m => m.someproperty) method knows validation property failed. that's part i'm not sure about.

by contrast, when return new view() actionresult (as http get), brand-new, shiny model instantiated. creating new model simple creating poco (plain old c# object) -- validation not triggered.

as client-side validation, handled through javascript once click form's submit button. when [httpget] request displays blank form, submit button hasn't yet been clicked (so javascript validation hasn't been started). in addition, believe once begin typing validation kicks in through various javascript events such change, keydown, keypress, etc.


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 -