有什么方法可以将脚本值发送到MVC中受保护的重写void OnActionExecuted

时间:2018-08-14 21:31:16

标签: jquery asp.net-mvc

我想将单选按钮值发送到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();

                }
            })

0 个答案:

没有答案