在回调期间永远不会保存ViewState

时间:2012-03-11 12:10:17

标签: asp.net viewstate

我在这里尝试做的是从客户端调用一个函数,它将调用“RaiseCallbackEvent”,我试图将参数(从客户端)存储到viewstate中。然而,在回调期间从不保存viewState,为什么?

        public partial class _Default : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
        ....
        protected void Page_Load(object sender, EventArgs e)
        {

        ClientScriptManager cm = Page.ClientScript;
        String cbReference = cm.GetCallbackEventReference(this, "arg",
            "ReceiveServerData", "");
        String callbackScript = "function CallServer(arg, context) {" +
            cbReference + "; }";
        cm.RegisterClientScriptBlock(this.GetType(),
            "CallServer", callbackScript, true);
        }
       .....
       public void RaiseCallbackEvent(String eventArgument)
       {
           ViewState["attribute"] = eventArgument;
       }
       .....

1 个答案:

答案 0 :(得分:0)

ViewState不适用于javascript;但是,缓存是。