asp.net mvc - MVC RadioButtonFor default checked when enum but not for int in viewmodel -
noticed new thing today while trying solve problem have.
viewmodel:
[required] public paymentoption paymentoption { get; set; } enum:
public enum paymentoption { creditcard, invoice } view:
<div> @html.radiobuttonfor(x => x.paymentoption, paymentoption.creditcard, new dictionary<string, object> {{ "id" , "cc" }}) credit card @html.radiobuttonfor(x => x.paymentoption, paymentoption.invoice, new dictionary<string, object> {{ "id" , "in" }}) invoice </div> if changed paymentoption property int none of radiobuttons checked default when rendering view.
public int paymentoption { get; set; } if paymentoption property paymentoption enum 1 of radiobuttons checked default , in html source input radio has checked=checked.
public paymentoption paymentoption { get; set; } why behavior? shouldn't same both int , enum paymentoption property?
Comments
Post a Comment