繁体   English   中英

是否可以更新ViewBag变量?

[英]Is it possible to update a ViewBag variable?

可以使用页面上的javascript方法增加viewbag变量吗? 我有以下尝试:

function ConfirmFriend(friendID, addOrDecline) {

      alert(addOrDecline);

      if (parseInt(@ViewBag.ActualFriendCount) == 0 && addOrDecline == "add")
      {             
          alert("THIS IS A FIRST ADD");
          @{
              int test = Convert.ToUInt32(@ViewBag.ActualFriendCount);
              test++;
              @ViewBag.ActualFriendCount == test;
          }
      }

    var userID = '@ViewBag.UserID';

    var postData = {
        'userID': userID,
        'userFriendID': friendID,
        'addOrDelete': addOrDecline
    };

    $.post('/User/Show/', postData, function (data) {
    });

    document.getElementById("HiddenPendingFriends" + friendID).style.display = 'none';

    if (addOrDecline == 'add') {
        document.getElementById("HiddenAcceptedFriends" + friendID).style.display = 'block';
    }
    else {
        document.getElementById("HiddenDeclinedFriends" + friendID).style.display = 'block';
    }
};

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM