Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Global Variables C#
Message
From
18/12/2009 18:54:28
 
 
To
18/12/2009 17:15:03
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01438724
Message ID:
01439885
Views:
46
So, you probably didn't wade through all the other posts in this thread. <g> You don't actually have to instantiate the AppUserClass to set the AppUserID. Since it's all static, you really only have to do this, no instantiating needed:

AppUserClass.AppUserID = "MyID";

Now, if you have other stuff you're doing in the constructor, then the above probably isn't what you want to do. But, if not, then simply setting the static property is just fine (and easier).

~~Bonnie




>>>you need to use static properties and/or methods.
>
>>>~~Bonnie
>
>
>Guess what, I'm returning to the thread topic:
>
>My first from calls the login screen and after validation, passes the userid as a parameter when instantiating AppUserClass.
>I couldn't figure out how to pass a parameter to a static class or to a static constructor in a non static class, so I kept futzing around and this worked. I can acces the userid in other forms of the app.
>
>This works so, I'm out of the woods, but I'm wondering if there's a better way.
>
>
>
>
>   public class AppUserClass
>     {
>
>      public AppUserClass(string UserId )
>       {
>          AppUserId = UserId;
>
>       }
>
>      private static string appUserId;
>      public static string AppUserId 
>      {
>
>         get
>         {
>            return appUserId;
>         }
>         set
>         {
>            appUserId = value;
>         }
>
>      } // end property AppUserId
>      
>    } // end class AppUser
>
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform