Solved

Getting Property Value of BasePage to a Static Method

Posted on 2008-10-18
7
300 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

932 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

9 Experts available now in Live!

Get 1:1 Help Now