asp.net mvc - Adding model with user input and hard coded values -



asp.net mvc - Adding model with user input and hard coded values -

okay using mvc framework. have view adding model. @ moment using default "create" controller.

i want able create model own variables pre-set. illustration model.userid want set users id. want values inputed user , want set. there way this

(pseudo code)

model.matchid = 123 model.prediction type = "user input" add together model

here current code below

@using (html.beginform()) { @html.validationsummary(true) <fieldset> <legend>predictions</legend> <div class="editor-label"> @html.labelfor(model => model.matchid, "match") </div> <div class="editor-field"> @html.dropdownlist("matchid", string.empty) @html.validationmessagefor(model => model.matchid) </div> <div class="editor-label"> @html.labelfor(model => model.userid, "user") </div> <div class="editor-field"> @html.dropdownlist("userid", string.empty) @html.validationmessagefor(model => model.userid) </div> <div class="editor-label"> @html.labelfor(model => model.type) </div> <div class="editor-field"> @html.editorfor(model => model.type) @html.validationmessagefor(model => model.type) </div> <div class="editor-label"> @html.labelfor(model => model.prediction) </div> <div class="editor-field"> @html.editorfor(model => model.prediction) @html.validationmessagefor(model => model.prediction) </div> <p> <input type="submit" value="create" /> </p> </fieldset>

}

in controller, set values on model before returning view.

public class homecontroller : controller { public actionresult about() { var model = new mymodel(); model.someid = 123; model.someotherproperty = "hello world"; homecoming view(model); } }

asp.net-mvc razor

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -