Session value in asp.net application.

Posted by Gokul under ASP.NET on 1/12/2012 | Points: 10 | Views : 1724 | Status : [Member] | Replies : 2
Dear Friends,
I have a page called home page and a master page. this master page is shown in home page. I have placed a label control in the master page. I have login controls in the home page. When the user enters into the application, the label should display as Guest. After entering the login credentials and moving to other pages in the application, the label should display the username from the textbox value that has been entered during the login process.

When ever the application is opened, the label should display as guest. If the application is closed or started, i want all the session values to be cleared.
How can i acheive this.


Regards,
Gokul.

Thanks and Regards,
GokulNath Nithy.



Responses

Posted by: Gow.net on: 1/12/2012 [Member] Starter | Points: 25

Up
0
Down
sir try this
in master page
label1.Text=session["username"].ToString();

in home page
click login button event
session["username"]=txtusername.Text;

Response.Redirect(""Homepage.aspx);


gowthaman8870226416

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jpchoudhari on: 1/12/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

you can use this.

if(Session["UserName"] != null)

lblUser.Text=Session["UserName"].ToString();
Else
lblUser.Text="Guest";


Kind Regards,
Jay

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response