session variable not working properly

G

Gurunadh

Hi

i've some web user controls in one folder and web pages in some other
folder.

and i've included header web user control in all my web pages.
and in that user control wrote code to get the logged in user details to be
displayed in header.

In login user control, the logged in userid was stored in a session.

in one of web pages i'm retrieving the values based on the value stored in
session i set in login control.

and when i put cooment to the code in header control then the value is
maintained in session, if i remove comments then it is not storing any data
in session.

whats the problem with my code?

Thanks And Regards
Yoshitha.
 
M

Masudur

Dear Gurunadh,

Just Make sure you are not overriding the session variable in the
Header control.
A user controls page load event is raised after page's pageload event
is raised. so if you store or clear session in user control it will
override the value of the page's code.

But it will be helpful if you provide sample code in header control.

Thanks

Md. Masudur Rahman
www.kaz.com.bd
KAZ Software Ltd.
Software outsourcing made simple...
 
G

Gurunadh

Hi Rahman


private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

if(! IsPostBack)

{

ePortalDataBase db=new ePortalDataBase();

OleDbConnection con;

con=db.openconnection();

con.Open ();

if(db.RunQuery("Select aliasname,sitetitle from EL_PortalRegistration where
siteaddress='siteadress' "))

{

while(db.result.Read())

{

lblUser.Text=db.result.GetValue(0).ToString() ;

lblTitle.Text=db.result.GetValue(1).ToString() ;

}

}

con.Close();

}



private void btnSignOut_Click(object sender, System.EventArgs e)

{

Session.Abandon();

Server.Transfer("default.aspx");

}

this is the code i've written in header control



and this code i've writen in login control



private void btnLogin_Click(object sender, System.EventArgs e)

{

Session["EmailId"]=txtEmailId.Text;

Response.Redirect("Eportal_Courses.aspx") ;

}

thanks and REgards

Yoshitha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top