Hi,
How to create simple registration page with username ,pwd, screen name, security question with validation coding
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
SenthilkumarRank #387 · 6.5K reputationPosted Apr 10, 2012, 1:41 AM EDT
Design page:
Code file:
Satyapriya NayakRank #47 · 31.5K reputationPosted Apr 10, 2012, 6:40 AM EDT
Try this...
Here all types of validation are provided.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Create_a_user_account_Csharp._Default" %>
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;
namespace Create_a_user_account_Csharp
{
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
DataSet ds;
string str;
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select * from secret";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
ddlsecurityquestion.Items.Add(reader["secretqno"].ToString());
}
reader.Close();
con.Close();
}
protected void b1_Click(object sender, EventArgs e)
{
Session["name"] = txtname.Text;
SqlConnection con = new SqlConnection(connStr);
com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.Text;
com.CommandText = "insert into useraccount(userid,name,password,confirmpassword,email,securityquestion,securityanswer) values(@userid,@name,@password,@confirmpassword,@email,@securityquestion,@securityanswer)";
com.Parameters.Clear();
com.Parameters.AddWithValue("@userid", txtid.Text);
com.Parameters.AddWithValue("@name", txtname.Text);
com.Parameters.AddWithValue("@password", txtpassword.Text);
com.Parameters.AddWithValue("@confirmpassword", txtconfirmpassword.Text);
com.Parameters.AddWithValue("@email", txtemail.Text);
com.Parameters.AddWithValue("@securityquestion", ddlsecurityquestion.SelectedValue);
com.Parameters.AddWithValue("@securityanswer", txtsecurityanswer.Text);
if (con.State == ConnectionState.Closed)
con.Open();
com.ExecuteNonQuery();
con.Close();
Response.Redirect("success.aspx");
}
}
}
Thanks
If this post helps you mark it as answer