c# - Does a model need to be explicitly passed to a view if the model is strongly bound to the view? -
i have example project i'm working on in particular model passed on view controller, this:
result = view(stu) //stu object of type student // // return result; in particular view, @ top have @model project.models.student , have textboxes bind information entered model. however, in controller have method has following code:
// // result = view(); // and view has @model.project.models.login, can still bind things model view in other view (eg, have like:
@html.textboxfor(model => model.login_name, new { maxlength = "30" }) i didn't pass model view did in first method, , yet seems have same functionality. if using @model @ top of view, mean not necessary explicitly pass model object parameter controller method?
if declare @model @ top of cshtml page, page expect model of type have declared. of course can choose not use model in page, , in situation declare useless. in addition can declare model, don't send object view. if send object, must same type declare in @model.
Comments
Post a Comment