更改viewstate值 [英] changing the viewstate value

查看:61
本文介绍了更改viewstate值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi


如果View State值为X且我在Page_Load中将其更改为Y那么View State的最终值是多少?



提前感谢

hi
If View State value is "X" and I have changed it to "Y" in Page_Load then what will be the final value of View State?

thanks in advance

推荐答案

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class About : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ViewState["xx"] = "x";
        if (!IsPostBack)
        {
            ViewState["xx"] = "y";
        }
        Response.Write(ViewState["xx"]);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }
}







在这种情况下第一页加载返回值''y''...当你点击btn而不是它的返回

''x ''.....




in this case first page load return value ''y'' ... and when u click the btn than it''s return
''x'' .....


这篇关于更改viewstate值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆