Solved

Getting Property Value of BasePage to a Static Method

Posted on 2008-10-18
7
322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to implement server side field validation and display customized error messages to the client.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 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