我想在我的登录页面中为“记住我”选项使用翻转开关。发布表单时,视图模型的 RememberMe 属性不会从翻转开关中获取值。
查看型号:
public class LogOnViewModel
{
private bool _RememberMe;
/*some other properties here...*/
[DisplayName("Remember Me?")]
public Nullable<bool> RememberMe
{
get
{
return (_RememberMe);
}
set
{
_RememberMe = (value ?? false);
}
}
}
看法:
@model UI.Models.Authenticate.LogOnViewModel
@using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { data_ajax = "false" }))
{
<div>
<div data-role="fieldcontain">
@Html.LabelFor(m => m.LoginUserName)
@Html.TextBoxFor(m => m.LoginUserName)
</div>
<div data-role="fieldcontain">
@Html.LabelFor(m => m.LoginPass)
@Html.PasswordFor(m => m.LoginPass)
</div>
<select name="RememberMe.Value" id="Model.RememberMe.Value" data-role="slider">
<option value="false">No</option>
<option value="true" selected="">Yes</option>
</select>
<input type="submit" data-role="button" data-transition="none" value="Log on" />
</div>
}
表单发布后,RememberMe 值始终为 false。如何正确将 RememberMe Value 绑定到 fip 开关?