我想将单选按钮值发送到protected override void OnActionExecuted
内部的控制器_Layout
。
有人可以建议我该怎么做吗?
_Layout
<div class="NorthSouthHemisphere">
@Html.RadioButton("NorthernSouthernHemisphere", "NH")Northern
@Html.RadioButton("NorthernSouthernHemisphere", "SH")Southern
</div>
控制器
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (User != null)
{
var context = new ApplicationDbContext();
var username = User.Identity.Name;
if (!string.IsNullOrEmpty(username))
{
var user = context.Users.SingleOrDefault(u => u.UserName == username);
var Account = context.Account.SingleOrDefault(u => u.AccountId == user.AccountID);
var Country = context.Country.SingleOrDefault(u => u.CountryId == user.CountryID);
string fullName = string.Concat(new string[] { user.FirstName, " ", user.LastName });
}
}
Hemishpere();
base.OnActionExecuted(filterContext);
}
脚本
$(document).on('change', '.NorthSouthHemisphere input[type = "radio"]', function () {
var selectedVal = "";
var selected = $(".NorthSouthHemisphere input[type='radio']:checked");
if (selected.length > 0) {
selectedVal = selected.val();
}
})