Create Login Page using sql procedure In Asp.Net
http://www.programmerschoice.com/tutorials/AspDotNet_Details.aspx?ProgramName=Create%20Login%20Page%20using%20sql%20procedure%20In%20Asp.Net
http://www.programmerschoice.com/tutorials/AspDotNet_Details.aspx?ProgramName=Create%20Login%20Page%20using%20sql%20procedure%20In%20Asp.Net
Description Likes 0
Log in User using Exist Database in asp.ne by using sql store procedure Access userinformation
Log in User using Exist Database in asp.ne by using sql store procedure Access userinformation
Html Source Code :
C# Code Behind
01 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> |
02 |
03 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
04 | < html xmlns = "http://www.w3.org/1999/xhtml" > |
05 | < head id = "Head1" runat = "server" > |
06 | < title ></ title > |
07 | < link href = "css/stylesheet.css" rel = "stylesheet" type = "text/css" /> |
08 |
09 | < style type = "text/css" > |
10 | .style1 |
11 | { |
12 | width: 100%; |
13 | } |
14 | </ style > |
15 |
16 | </ head > |
17 | < body > |
18 | < form id = "form1" runat = "server" > |
19 | |
20 | < div class = "back-form" style = "padding: 10px; margin: 25%; font-family: verdana" > |
21 | Login: Login using SQL Procedure< br /> |
22 | < br /> |
23 | < table class = "style1" > |
24 | < tr > |
25 | < td > |
26 | UserName</ td > |
27 | < td > |
28 | : |
29 | < asp:TextBox ID = "TextBox1" runat = "server" CssClass = "textbox-style" |
30 | Width = "210px" ></ asp:TextBox > |
31 | </ td > |
32 | </ tr > |
33 | < tr > |
34 | < td > |
35 | Password</ td > |
36 | < td > |
37 | : |
38 | < asp:TextBox ID = "TextBox2" runat = "server" CssClass = "textbox-style" |
39 | Width = "210px" ></ asp:TextBox > |
40 | </ td > |
41 | </ tr > |
42 | < tr > |
43 | < td > |
44 | </ td > |
45 | < td > |
46 | |
47 | < asp:Button ID = "Button1" runat = "server" CssClass = "black-button" |
48 | onclick = "Button1_Click" Text = "Login" /> |
49 | </ td > |
50 | </ tr > |
51 | </ table > |
52 | < br /> |
53 | < asp:Label ID = "Label1" runat = "server" ></ asp:Label > |
54 | </ div > |
55 | |
56 | </ form > |
57 | </ body > |
58 | </ html > |
01 | using System; |
02 | using System.Configuration; |
03 | using System.Data; |
04 | using System.Linq; |
05 | using System.Web; |
06 | using System.Web.Security; |
07 | using System.Web.UI; |
08 | using System.Web.UI.HtmlControls; |
09 | using System.Web.UI.WebControls; |
10 | using System.Web.UI.WebControls.WebParts; |
11 | using System.Data.SqlClient; |
12 |
13 |
14 | public partial class _Default : System.Web.UI.Page |
15 | { |
16 | string connection = ConfigurationManager.ConnectionStrings[ "ConnectionString" ].ConnectionString; |
17 | protected void Page_Load( object sender, EventArgs e) |
18 | { |
19 |
20 | } |
21 | protected void Button1_Click( object sender, EventArgs e) |
22 | { |
23 | DataSet ds = new DataSet(); |
24 | string getrecord = "Select * from LoginInfo where UserName='" + TextBox1.Text + "' and Pass='" + TextBox2.Text + "' " ; |
25 | SqlDataAdapter ad = new SqlDataAdapter(getrecord, connection); |
26 | ad.Fill(ds); |
27 |
28 | if (ds.Tables[0].Rows.Count > 0) |
29 | { |
30 |
31 | Label1.ForeColor = System.Drawing.Color.Green; |
32 | Label1.Text = "Your UserName and Password is Correct " ; |
33 | } |
34 | else |
35 | { |
36 | Label1.ForeColor = System.Drawing.Color.Red; |
37 | Label1.Text = "Your UserName and Password is Invalid !!" ; |
38 | } |
39 | } |
40 | } |
No comments:
Post a Comment