lakshmidurga
asked on
Using ViewState in c# code
Hi,
I want to access a variable through out my project.So,i am using a viewstate .
I am assigning value for a viewstate variable in this way
viewstate["username"]="xxx " in one page ,
i am not able to acess it it another page in the same project.
Is there anything i need to do to access it through out the project.
I want to access a variable through out my project.So,i am using a viewstate .
I am assigning value for a viewstate variable in this way
viewstate["username"]="xxx
i am not able to acess it it another page in the same project.
Is there anything i need to do to access it through out the project.
//it is not Sessions
//First Page
Session["username"]="xxx"
//Second Page
string strtest=Session["username" ].ToString ();
//First Page
Session["username"]="xxx"
//Second Page
string strtest=Session["username"
ASKER
Hi
I have tried session.But,i am facing problems with session variables,when deployed in IIS.I am getting object reference not set to an object error at the statement
Session["xx"]="xxx"
if i comment out that statement it is functioning well.
This statement even working fine when i run my application using visual studio 2005.
Please help me in any other necessary code i need to code when using sessions in c#.
I have used session variables many times with vb.net code.They went well.This is the first time i am writing c# code.
I have tried session.But,i am facing problems with session variables,when deployed in IIS.I am getting object reference not set to an object error at the statement
Session["xx"]="xxx"
if i comment out that statement it is functioning well.
This statement even working fine when i run my application using visual studio 2005.
Please help me in any other necessary code i need to code when using sessions in c#.
I have used session variables many times with vb.net code.They went well.This is the first time i am writing c# code.
please post u r code
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
//First Page
Sessions["username"]="xxx"
//Second Page
string strtest=Sessions["username