c# - Setting value of CheckBoxFor -


i trying set checkbox value (true/false) field. can value, cannot set it.

within model have:

public bool receivenewsletter { get; set; } 

in view have:

model project.models.parent @using (ajax.beginform("register", "parentregister", new ajaxoptions { httpmethod = "post", updatetargetid = "parent_register" })) {    @html.checkboxfor(u => u.receivenewsletter, new { @class = "checkbox", type = "checkbox" }) } 

in controller have:

 [httppost]  public actionresult register(models.parent register)  {     return content(register.selectedindex.tostring());  } 

when load application, checkbox unchecked because receivenewsletter false however, when check checkbox , click submit, doesn't set value true

does know doing wrong?

i don't know action method looks like(i'm assumed correct), passing in type of parent named register httppost action method. httppost action method should like:

[httppost] public actionresult register(models.parent register) {     return content(register.receivesnewsletter.tostring()); } 

i think helpful if showed action method can make sure answer looking for. going leave comment under question, don't have enough points that.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -