Solved

Getting Property Value of BasePage to a Static Method

Posted on 2008-10-18
7
311 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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 selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

825 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