asp.net mvc - how to set default value HTML.TextBoxFor() -


i have view consisting of form , textboxes. how can set default value in each box strings , int values?

i want page load each box's value don't need type values.

i'm not able change in model.

@model mydb.production.productionmaterial  @{   viewbag.title = "creatematerial";  }   @using (html.beginform()) {   @html.validationsummary(true)   <fieldset>     <legend>productionordermaterial</legend>      <div class="editor-label">         @html.labelfor(model => model.position)     </div>     <div class="editor-field">                   //something         @html.textboxfor(model => model.position, or 5 )         @html.validationmessagefor(model => model.position)     </div>      <div class="editor-label">         @html.labelfor(model => model.articleid)     </div>     <div class="editor-field">                  //something         @html.textboxfor(model => model.articleid. or "")         @html.validationmessagefor(model => model.articleid)     </div>   } 

create instance of model in action, assign values properties of model , pass view method.

in action have:

productionmaterial model = new productionmaterial(); model.position = 5; return this.view(model); 

this pass model view , textboxfor( model => model.position ) display 5.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -