hi i'm trying run checkbox field in mvc base on video tutorial i've watch https://www.youtube.com/watch?v=4keoopwshmw&list=pl6n9fhu94yhvm6s8i2xd6nyz2zord7x2v&index=38, follow carefully. there problem checkbox not showing in browser.
it shows text 12345 , button submit.
index.cshtml
@model ienumerable<mvccheckbox.models.city> @{ viewbag.title = "home"; } <h2>index</h2> @using (html.beginform()) { @html.editorformodel() <br /> <input type="submit" value="submit" /> }
city.cshtml
@model mvccheckbox.models.city @html.hiddenfor(x => x.id) @html.hiddenfor(x => x.name) @html.checkboxfor(x => x.isselected) @html.displayfor(x => x.name)
from watching video, missed step out:
right click on "editortemplates" folder - add - view. in "add view" dialog box, set view name = city view engine = razor , click "add".
then copy , paste code it:
@{ viewbag.title = "city"; } @html.hiddenfor(x => x.id) @html.hiddenfor(x => x.name) @html.checkboxfor(x => x.isselected) @html.displayfor(x => x.name)
Comments
Post a Comment