/
RegistrationInJavascript.aspx.cs
94 lines (85 loc) · 2.93 KB
/
RegistrationInJavascript.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class RegistrationInJavascript : System.Web.UI.Page
{
SqlCommand cmd;
SqlConnection conn;
SqlDataAdapter Adp;
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
if (IsPostBack == false)
CapturImg();
}
protected void BtnChangeImg_Click(object sender, EventArgs e)
{
CapturImg();
}
protected void CapturImg()
{
Random ran = new Random();
int i;
i = ran.Next(1, 5);
string str;
str = "Select * from Securityimg where Id =" + i;
cmd = new SqlCommand(str, conn);
Adp = new SqlDataAdapter(cmd);
ds = new DataSet();
Adp.Fill(ds);
ImgCaptch.ImageUrl = ds.Tables[0].Rows[0][1].ToString();
ViewState["code"] = ds.Tables[0].Rows[0][0].ToString();
}
protected void BtnReg_Click(object sender, EventArgs e)
{
if (CB1Accept.Checked)
{
string str, chk;
str = "select Ans from Securityimg where Id = " + Convert.ToInt16(ViewState["code"]);
cmd = new SqlCommand(str, conn);
conn.Open();
chk = cmd.ExecuteScalar().ToString();
conn.Close();
if (TBAns.Text == chk)
{
str = "insert into Registration (Firstname,Lastname,Countryid,Stateid,Cityid,Username,Password,Emailid) values( '" + TBFName.Text + "','" + TBLName.Text + "'," + DDLCountry.SelectedItem.Value + "," + DDLState.SelectedItem.Value + "," + DDLCity.SelectedItem.Value + ",'" + TBUName.Text + "','" + TBpass.Text + "','" + TBEmail.Text + "')";
cmd = new SqlCommand(str, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Response.Redirect("UserHome.aspx");
}
else
status.Text = "Invalid Code";
}
else
status.Text = "Please accept the terms and conditions";
string path = Server.MapPath("./");
Response.Write("path");
}
protected void TBUName_TextChanged(object sender, EventArgs e)
{
int num;
string str;
str = "Select count(*) from Registration where Username = '" + TBUName.Text + "'";
cmd = new SqlCommand(str, conn);
conn.Open();
num = Convert.ToInt16(cmd.ExecuteScalar());
conn.Close();
if (num == 0)
LBAvail.Text = "Valid UserName";
else
LBAvail.Text = "In Valid UserName";
}
}