473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

passing values

How do I pass a variable from one webpage to another in C# ?
I have created a UserLogin page which wants to pass the value of UserName to
another page called UserPage.

Help appreciated. Thanks.
Nov 17 '05 #1
4 1043
> How do I pass a variable from one webpage to another in C# ?
I have created a UserLogin page which wants to pass the value of
UserName to
another page called UserPage.

The easy way would be to use the Session object, which stores data for a
single user session. You could store the login user like this:

Session["UserName"] = "Andrew";

And you can retrieve it (in UserPage) like this:

string sUserName = Convert.ToString( Session["UserName"] );

Both lines may throw an exception if sessions are not enabled, or if the
variable wasn't set.

Greetings,
Wessel
Nov 17 '05 #2
If it's only something small then you could use the Session to store it. I
say if it's only something small because if you use the Session too much then
your application scalability will quickly degrade.

Brian Delahunty
Ireland

http://briandela.com/blog
"Andrew" wrote:
How do I pass a variable from one webpage to another in C# ?
I have created a UserLogin page which wants to pass the value of UserName to
another page called UserPage.

Help appreciated. Thanks.

Nov 17 '05 #3
It worked. Thanks.

"Wessel Troost" wrote:
How do I pass a variable from one webpage to another in C# ?
I have created a UserLogin page which wants to pass the value of
UserName to
another page called UserPage.

The easy way would be to use the Session object, which stores data for a
single user session. You could store the login user like this:

Session["UserName"] = "Andrew";

And you can retrieve it (in UserPage) like this:

string sUserName = Convert.ToString( Session["UserName"] );

Both lines may throw an exception if sessions are not enabled, or if the
variable wasn't set.

Greetings,
Wessel

Nov 17 '05 #4
Ok Thanks

"Andrew" wrote:
How do I pass a variable from one webpage to another in C# ?
I have created a UserLogin page which wants to pass the value of UserName to
another page called UserPage.

Help appreciated. Thanks.

Nov 17 '05 #5

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

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
2
by: Morgan | last post by:
Thanks to all of you because I solved the problem related with my previous post. I simply made confusion with pointers to pointers and then succeeded passing the reference to the first element...
2
by: craigkenisston | last post by:
Hi, I created an array of objects like this : object Values = {myObject.myprop, otherobject.otherprop, thirdobject.xprop}; Then I pass it to a method. and I get the values filled in that...
1
by: olduncleamos | last post by:
Hello all. With a background in ASP, I am finding the work required for passing values between pages mystifying. For various obvious reasons, I have eliminated using cookies and session to store...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
2
by: o1j2m3 | last post by:
I created 2 forms, A and B using VB.NET 2003 in A, the codes are : ========================== public AsName as string public AsPrice as double public sub setValue(ByVal sname as string,...
1
by: vncntj | last post by:
I have a C#.NET that simply passes 6 values to a Stored Procedure. But I'm trying to get the (Default.aspx.cs page) to handle passing the values to the sp. The goal is to pass the values and see...
3
by: ishwarbg | last post by:
Hi Everyone, I have a .Net Application, through which I am invoking a function from a legacy DLL developed in C++. My structure in C# contains some data of type double which I need to pass to to...
2
by: csmith8933 | last post by:
How do I write a function where the number of parameters it takes varies? This is what I have but it doesnt work. // function prototype void functionThree(int num1=1, int num2=2, int num3=3);...
5
by: jmartmem | last post by:
Greetings, I have built an Update Record Form in an ASP page. This form contains a number of fields, such as text boxes and menus, to name a few. Upon clicking the 'submit' button, I want the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.