C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




dotnet


Posted Date: 13 Aug 2008      Total Responses: 1

Posted By: Musturu Thippa Reddy       Member Level: Silver     Points: 1



hi friends , i am doing a Job postal project for my satisfaction i had a problem in login page plzzzz send the code for login page plzzzzzzzzzz(In ASP.NEt with c#,sqlserver)




Responses

Author: Ramya    13 Aug 2008Member Level: GoldRating:     Points: 6

This is a sample. You should modify this for your requirement. Let’s say the name of the file is login.aspx.

Step 1: Create a design for the login page. For example, In the html type the following
<login.aspx>
<%@ Page language="c#" Codebehind=" login.aspx.cs" Inherits="login" %>

<html><body>
<form id="Form1" runat="server">

<p align=center>Login Form</P>
<p align=center><asp:Label id=”lblMsg” runat="server"></asp:Label></P>


<h4>Login</h4>
Username: <asp:TextBox id="txtUname" Runat="server" />
<asp:RequiredFieldValidator id="rfvUname" ControlToValidate="txtUname" ErrorMessage="Enter a valid user name" runat="server" />

<br/>
Password: <asp:TextBox id="txtPassword" Runat="server" TextMode="Password" />
<asp:RequiredFieldValidator ControlToValidate="txtPassword" ErrorMessage="Enter a valid password." id="rfvPassword" runat="server" />



<asp:Button id="btnSubmit" Runat="server" Text="Login" onClick="btnSubmit_Click" />
</form>
</body></html>

Step 2 : In the Code Behind, write the c# code for the login form
<login.aspx.cs>

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SQL;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace <namespace name>
{

public class login : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lblMsg.Text = "Enter Username and Password to Login";
}
}

protected void btnSubmit_Click(Object obj, EventArgs e)
{
if (Page.IsValid)
{
// check for username & password in the database
SQLConnection conn = new SQLConnection("<connectionstring>");

// Get the row corresponding the given username and password
string strSQL = "Select * From <tablename> Where <userid column name>='" +
txtUname.Text + "' and <password column name> = '" +
txtPassword.Text + "'";

SQLDataSetCommand dsc = new SQLDataSetCommand(strSQL, conn);

// Fill the dataset
DataSet ds = new DataSet();
dsc.FillDataSet(ds, "Users");

// if there no entry then the user is invalid
if (ds.Tables["Users"].Rows.Count == 0)
{
lblMsg.Text = "Invalid User Name and Password. Try Again.";
}
else
{
lblMsg.Text = "Welcome, " + txtUname.Text +
"!!! You have successfully signed in.";
}
}
}

}
}




Post Reply
You must Sign In to post a response.
Next : DHTML Editor
Previous : Solution configuration tool
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use