![](/img/trans.png)
[英]Is there any way to get the id of clicked value and send it to another page using Jquery?
[英]Are there any way to send value into protected override void OnActionExecuted in MVC
我想将单选按钮值发送到_Layout
内protected override void OnActionExecuted
控制器protected override void OnActionExecuted
。
谁能建议我该怎么做?
_布局
<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();
}
})
ActionExecutedContext
类可以访问HttpContext
的实例,因此,您必须采取的一种选择是在控制器中配置一个ActionResult
该控制器负责设置要在OnActionExecuted
内部访问的会话变量的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.