Link to home
Start Free TrialLog in
Avatar of DylanJones1
DylanJones1

asked on

Getting Property Value of BasePage to a Static Method

I have a static page method I am calling from a javascript function.  I need to check the DityFlag  for the page.    Since it is a Staic this.dirty will not work.  How can I check the dirty flag from within this static method.  
Avatar of CuteBug
CuteBug
Flag of India image

Static methods can only access static members.

So make your property static.

Then you can access it in the following way.

ClassName.DirtyFlag
Avatar of DylanJones1
DylanJones1

ASKER

OK...  

MyBasePage

        // The dirty state flag for data change checking
        private bool isDirty;
        /// <summary>
[Browsable(false)]
        public bool Dirty
        {
            get { return isDirty; }
            set { isDirty = value; }
        }

MyRealPage : BasePage


[System.Web.Services.WebMethod]

    public static void SetData()
    {

        if (ServiceReceipt.Dirty)
        {
             If ( MyRealPage.Dirty)
              {
                          DoMyFunction();
              }

        }


So  how should this look?  
Sorry had some typos...

MyBasePage

        // The dirty state flag for data change checking
        private bool isDirty;
        /// <summary>
[Browsable(false)]
        public bool Dirty
        {
            get { return isDirty; }
            set { isDirty = value; }
        }

MyRealPage : MyBasePage


[System.Web.Services.WebMethod]

    public static void SetData()
    {

             If ( MyRealPage.Dirty)
              {
                          DoMyFunction();
              }

       }


So  how should this look?  
It should look like this

// The dirty state flag for data change checking
        private static bool isDirty;
        /// <summary>
[Browsable(false)]
        public static bool Dirty
        {
            get { return isDirty; }
            set { isDirty = value; }
        }
And how would this we accessed in the staic method

[System.Web.Services.WebMethod]

    public static void SetData()
    {

             If ( MyRealPage.Dirty)
              {
                          DoMyFunction();
              }

       }

And also set  on the page itself  as I can no longer use this.Dirty = true;

ASKER CERTIFIED SOLUTION
Avatar of CuteBug
CuteBug
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Bug