473,809 Members | 2,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can I get a varibale from 2 forms in a project

Hi,

Sorry, maybe it's so simple. but please let me know.

I have Login.aspx.cs taht has a string variable like strUserName.
I have manage.aspx.cs that I want to get strUserName.
How can I do this?

Thank you.
Monica
Mar 5 '07 #1
1 1198
If you're using Forms Authentication - and it sounds as though you should
be - then you can get the user's credentials from the Identity propery of
the GenericPrincipa l object. Look up GenericPrincipa l in MSDN and follow
the trail to GenericIdentity for examples of how this works. Basically, the
Name property of the GenericPrincipa l's Identity property gives you what you
want.

If you need to roll your own you have several options. The easiest is just
to store the string in the Session:

Session["uid"] = strUserName;

You would do this in some convenient event handler in your Login.aspx page
codebehind - usually in the handler for the submit button, I guess, when
someone logs in.

If you're storing more information about your user than just the user name,
you'll probably want to create an object from a class you define, store the
username in that object (along with whatever else you want to put in there),
and store a reference to that object in the Session.

MyUserObj myuserobj = new MyUserObj();
myuserobj.usern ame = strUserName; // assuming username is a property
Session["MyUserObj"] = myuserobj;

Your object is now globally accessible.

Only your own application model (UML or whatever) will tell you which
strategy is best for your application.

HTH
Peter
"Monica" <Mo****@discuss ions.microsoft. comwrote in message
news:DC******** *************** ***********@mic rosoft.com...
Hi,

Sorry, maybe it's so simple. but please let me know.

I have Login.aspx.cs taht has a string variable like strUserName.
I have manage.aspx.cs that I want to get strUserName.
How can I do this?

Thank you.
Monica

Mar 5 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1912
by: Bob | last post by:
Declaring a module level form object in multiple froms within a project to show another project form causes a stack overflow and other assorted errors. Can anyone help?
6
2873
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and loop through all the forms in a database and pull information about the form (controls and properties). We would need to do the same in our VB.NET project; loop through the project and get the web form's control and property information...
3
1434
by: 20041210.20.eclipse | last post by:
Hi, I'm using MS Visual Studio .NET 2003 Standard on WinXP Home on a DELL Notebook. It is not possible to create a project that contains windows forms. When trying to create a Windows Forms application I get the error "The specified module could not be found". When trying to add Forms manually to a project I get the same error message. Previousely I used the Standard edition on XP Professional and was able to add Forms to my projects.
3
2723
by: Gustavo L. Fabro | last post by:
Greetings! I'm a newbie in Visual C++ .NET (have programmed in Borland C++ and Builder for long) and I am trying to do a very simple thing, but I'm stuck. I created an (unmanaged) DLL project with a sample function, and tried to call it from a ".NET Forms" project. All I get are "Unresolved External" errors from the Linker!
3
2508
by: Chris Dunaway | last post by:
A quick scan of the group did not immediately reveal an answer to my questions so here goes. First let me describe my app and then I'll ask the questions. I am writing a Windows Forms App (not Web Forms) that serves as a thin client to some web services. In other words, the Windows Forms app will be installed on the client machines and that app will call web services that are deployed on my server.
2
1980
by: Rob | last post by:
I was working on a project and everything was going fine, then all of a sudden the form set as my startup object stopped loading. I tried setting some others as the startup object, and some of my forms will load and others won't. Those that won't load at startup don't load with the Show or ShowDialog command either. Can anyone give me a hint as to what went wrong?
0
1595
by: Tony Johansson | last post by:
Hello! I have a very specific question and that is about how to inherit a visual control for example the control System.Windows.Forms.TextBox without causing the environment to delete the control when there are some compile errors. It's the same problem with any visual control that you inherit. The control is deleted as soon as you use the View Designer when there is compile error. It's very easy to reproduce my problem. You can do...
5
1474
by: Chris H | last post by:
Okay, I am trying to us a varialble with a list of number values as my data for an array, yet when I do this it doesnt return any values from the array, i was able to temporarily fix the proble by just doing s normal array setup in my function, but the problem is I want the ability to have teh array values to be changed easily in a varibale style config/include file... Here is the code i am working with... ...
5
1305
by: Siv | last post by:
Hi, I have a form in my project called "Uploader" and I want to access it from a menu within the main form using the following: Uploader frm = new Uploader(); frm.ShowDialog(); Where normally when I type the word "Uploader" the intellisense lists the form name ready for autocomplete I don't get it listed and if I manually
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10643
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10391
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.