Solved

Getting Property Value of BasePage to a Static Method

Posted on 2008-10-18
7
287 Views
Last Modified: 2012-05-05
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.  
0
Comment
Question by:DylanJones1
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:CuteBug
ID: 22749198
Static methods can only access static members.

So make your property static.

Then you can access it in the following way.

ClassName.DirtyFlag
0
 

Author Comment

by:DylanJones1
ID: 22749232
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?  
0
 

Author Comment

by:DylanJones1
ID: 22749273
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?  
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 16

Expert Comment

by:CuteBug
ID: 22749287
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; }
        }
0
 

Author Comment

by:DylanJones1
ID: 22749315
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;

0
 
LVL 16

Accepted Solution

by:
CuteBug earned 500 total points
ID: 22749320
Accessing in the static method

[System.Web.Services.WebMethod]
    public static void SetData()
    {

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

       }

Setting the value
MyRealPage.Dirty = true;
0
 

Author Closing Comment

by:DylanJones1
ID: 31507449
Thanks Bug
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now