2

我有一个.aspx包含打开popup按钮单击的按钮的页面。弹出窗口有AJAXFileUpload控制权。单击按钮打开弹出窗口时,session会将值发送到弹出窗口,并将page load这些session值分配给ViewStateHiddenFieldDataTable

问题: 当我clickUpload弹出窗口中的按钮上包含AjaxFileUpload它时,会将图像保存到AJAXUploadComplete event. 在这种情况下,我无法访问ViewState,HiddenField and DataTable值不知道为什么?

弹出窗口.aspx.cs

    DataTable dt=new DataTable();
     protected void Page_Load(object sender, EventArgs e)
        {

                int noOfImages;
                string[] imagePaths;
                if (dt != null && dt.Rows.Count==0)
                {
                    dt.Columns.Add("QuoteID");
                    dt.Columns.Add("PrepID");
                    dt.Columns.Add("IsPrep");
                    dt.Rows.Add(string.Empty, string.Empty, string.Empty);
                }
                if ((!IsPostBack ))
                {
                    if (Session["IsPrep"] != null || ViewState["IsPrep"]!= null)
                    {
                       int Isprep = Convert.ToInt32(Session["IsPrep"].ToString());

                       if (Session["IsPrep"] != null)
                       {
                           ViewState["IsPrep"] = Session["IsPrep"];
                           ViewState["QuoteID"] = Convert.ToString(Session["QuoteIDForListing"]);
 int intQuoteID = Convert.ToInt32(ViewState["QuoteID"]);
                        hdnQuoteID.Value = intQuoteID.ToString();
                           ViewState["PrepID"] = Convert.ToString(Session["PrepIDForListing"]);

                           if (dt != null && dt.Rows.Count > 0)
                           {
                               dt.Rows[0]["QuoteID"] = Convert.ToString(Session["QuoteIDForListing"]);
                               dt.Rows[0]["PrepID"] = Convert.ToString(Session["PrepIDForListing"]);
                               dt.Rows[0]["IsPrep"] = Convert.ToString(Session["IsPrep"]);
                           }

                           Session["IsPrep"] = null;
                           Session["QuoteIDForListing"] = null;
                           Session["PrepIDForListing"] = null;

                       }
                    }
                 }
       }

 protected void AjaxFileUpload1_UploadComplete1(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
         //here: ViewState,HiddenField,DataTable values are all get cleared dont know why?
            if (dt != null && dt.Rows.Count > 0)
            { 
                //here dt is set to null any idea?
            }
           //if (!string.IsNullOrEmpty(Convert.ToString(ViewState["QuoteID"])))
                if (!string.IsNullOrEmpty(Convert.ToString(hdnQuoteID.Value))&& hdnIsPrepId.Value=="0")
                {
                    int QuoteID = Convert.ToInt32(ViewState["QuoteID"]);
                    ///some code here
                }
               // else if (!string.IsNullOrEmpty(Convert.ToString(ViewState["PrepID"])))
                else if (!string.IsNullOrEmpty(Convert.ToString(hdnPrepID.Value)) && hdnIsPrepId.Value == "1")
                {
                    int PrepID = Convert.ToInt32(ViewState["PrepID"]);
                   ///some code here
                }
    }

注意:相同的功能在页面上运行良好。但是,与弹出窗口一起使用时,它HiddenField,DataTable,ViewState. Session会在弹出窗口打开后刷新所有不能用于存储数据的值,因为一次可能会打开多个窗口实例。

此外,当query string 与 Popup 一起使用以发送值时,会在附加contextkey 和 guidAjaxFileUpload时给出错误。its own querystring

请提出任何解决方案/更改?

4

0 回答 0