c# - how to pass entire model (with data) from view to controller? -


i don't know, may silly question trying find way solve this. need return entire model information (data) controller though of model properties not using in view. need them in controller action. example id, lable value.

example

 <div class="col-md-6">         @html.labelfor(model => model.abstracttitleinenglishlabel,          model.abstracttitleinenglishlabel, new { @class = "control-label mandatory" })  </div> 

from above first time able see label property value abstract title (in english). after submitting controller not getting value in controller model.. if return same view controller.

i can see property namel ike abstracttitleinenglishlabel, not value. means value of property not storing in model when passing controller.

 [httppost]  public actionresult index(meetingabstract meetingabstract)     {         if (!modelstate.isvalid)         { // re-render view when validation failed.             return view(meetingabstract);                       }                } 

how handle without using @html.hiddenfor?. because have lots of lables want show.

i think, best understanding of needs question, may have add data annotations on models.

using system; using system.componentmodel; namespace myproject.models {     public class mymodel     {         [displayname("abstract title")]         public string abstracttitleinenglish { get; set; }     } } 

data annotation ([displayname("abstract title"]) serve display text label. , when use helper method below, label text displayed "abstract title" regardless of post or get.

you have use helper method this:

@html.labelfor(model => model.abstracttitleinenglishlabel, new { @class = "control-label mandatory" }) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -