可以使用页面上的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';
}
};