Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 23803 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > Help of session shown email id into next page ...
Sandeepraturi

Help of session shown email id into next page

 Code Snippet posted by: Sandeepraturi | Posted on: 10/19/2012 | Category: C# Codes | Views: 263 | Status: [Member] | Points: 40 | Alert Moderator   


//Database field

id= int(auot increment and primary key)
username=varchar(50)
password=varchar(50)

//sessionexample.aspx

<div>
<pre>
Email: <asp:TextBox ID="name" runat="server"></asp:TextBox>
password:<asp:TextBox ID="pass" runat="server" TextMode="Password"></asp:TextBox>
<asp:Button ID="btn" runat="server" Text="login"
onclick="btn_Click" />
</pre>
</div>

//c# code for sessionexample.aspx

protected void btn_Click(object sender, EventArgs e)
{
SqlDataAdapter dap = new SqlDataAdapter("select * from login where username='"+name.Text+"' and password='"+pass.Text+"'",con);
DataSet ds = new DataSet();
dap.Fill(ds);
Session["username"] = ds.Tables[0].Rows[0][1].ToString();
Response.Redirect("sessionexample2.aspx");
}

now we get the session ,create new page sessionexample2.aspx

<head>
<style type="text/css">a {text-decoration: none}</style>
</head>

<div>
<asp:Label ID="lb" runat="server" ForeColor="#6699FF" ></asp:Label> <a href="sessionexample.aspx" style="text-decoration: none; ">logout</a>
</div>

//c# code for sessionexample2.aspx

protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack != true)
{

lb.Text = Session["username"].ToString();

}
}

Thanx
With Best Regards
Sandeep Raturi(software engineer)
Email: s.raturi89@gmail.com
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/20/2013 11:15:35 AM