Ajaxpro方法获取要重新初始化的全局页面变量?

问题描述 投票:0回答:2

我对ajaxpro方法有疑问。在.cs文件中,我为页面定义了一些全局变量,例如:

public partial class Admin : System.Web.UI.Page
{
    public int localidMember = 9;
    protected void Page_Load(object sender, EventArgs e)
    {

        AjaxPro.Utility.RegisterTypeForAjax(typeof(Admin));


        if (HttpContext.Current.Session["HomeOwn_ID"] != null)
        {
            localidMember = Convert.ToInt32(HttpContext.Current.Session["HomeOwn_ID"].ToString());

        }

    }


    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    public string LoadInbox()
    {
        // I need to use the variable localidMember and expected that it will have the value that I have set to pageload.., but it didnt. The variable is reinitialized to 9... Anyone have any ideas what's going on... Thanks so much ! 
    }

}
asp.net global-variables pagemethods ajaxpro
2个回答
1
投票

我想你做不到;因为在AjaxPro中,您不能处理控件属性。


0
投票

AjaxMethod将具有其自己的上下文。因此,将无法在其中访问localidMember。您可以考虑将其作为参数传递。

© www.soinside.com 2019 - 2024. All rights reserved.