开发者

preserve value of hidden variable over round trips

I need to maintain a unique identifier over server round trips. This开发者_如何学JAVA is applicable for any pages in the website. Hence the value of the unique identifier is stored inside a from in a hidden variable in the application master page.

What is the best way to preserve this value over round trips? I am using ASP.net

Thanks,


Store value in Session and set value of the HiddenField on the first time page loaded:

private string MyUniqiueId
    {
        get { return Session["MyUniqiueId"] as string; }
        set { Session["MyUniqiueId"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            MyUniqiueIdHiddenField.Value = MyUniqiueId;
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜