how to show username

Posted by Suneel161 under Regular Expressions on 3/31/2010 | Views : 5160 | Status : [Member] | Replies : 3
hii

i'm using session in login page.how to show username when i login into next page.
help me out




Responses

Posted by: Vuyiswamb on: 3/31/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
lets say you have a Session

Session["Username"]; = "Vuyiswamb";



and if the login is Successfully then in the other page or same page you can access and assign the usrename like this

txtUsername.Text = Session["Username"];


and when the user logout you must abandon the session.

Thank you for posting at Dotnetfunda
[Administrator]

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

Posted by: Rajujrk on: 3/31/2010 [Member] Starter

Up
0
Down
Add username in login page like below,
[code]
Session["username"]="Rajkumar";
[/code]
then call this session name in next page or any page in your web application like,
[code]
Welcome <b><%=Session["username"].toString()%></b>
[/code]

Then the Ouput Shows Like


Welcome Rajkumar


Thanks & Regards

Rajkumar J

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

Posted by: Sagarp on: 3/31/2010 [Member] Bronze

Up
0
Down
write

Defacult.aspx 1

<table style="width:40%;">

<tr>
<td class="style5">
&nbsp;</td>

<td class="style6" align="center">
<h1>
Log In</h1>
</td>

</tr>
<tr>
<td class="style4">
User Name</td>
<td class="style2">
<asp:TextBox ID="TextBox1" runat="server" Height="20px" Width="250px"
style="font-family: Verdana"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
Password</td>
<td class="style2">
<asp:TextBox ID="TextBox2" runat="server" Height="20px" Width="250px"
style="font-family: Verdana" AutoCompleteType="Disabled"
TextMode="Password"></asp:TextBox>
</td>

</tr>
<tr>
<td class="style5">
&nbsp;</td>
<td class="style2">
<asp:Button ID="btnLogin" runat="server" Height="27px" Text="Log In"
Width="70px" onclick="Button1_Click" Font-Italic="False"
style="font-family: Verdana" /> &nbsp;&nbsp;&nbsp;
<asp:Label ID="lblError" runat="server" ForeColor="#990000"
style="font-family: Verdana"></asp:Label>
</td>

</tr>
</table>


.cs


Session["User"] = strUser.ToString();
Response.Redirect("page2.aspx");



display next paage

page2.aspx

<asp:Label ID="lblUserName" runat="server" Text="Guest"></asp:Label>



.cs

p
rotected void Page_Load(object sender, EventArgs e)

{
strUserName = Session["User"].ToString();
lblUserName.Text = Session["User"].ToString();
}


Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/

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

Login to post response