Registration Form Not working
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BEL
{
public class BELRegister
{
public string Name { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
}
}
DalRegister.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using BEL;
using System.Data.SqlClient;
using System.Configuration;
namespace DAL
{
public class DALRegister
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Dbconnection"].ToString());
public int UserDetails(BELRegister br)
{
try
{
SqlCommand cmd = new SqlCommand("prcregisteration", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name", br.Name);
cmd.Parameters.AddWithValue("@username", br.UserName);
cmd.Parameters.AddWithValue("@password", br.Password);
cmd.Parameters.AddWithValue("@email", br.Email);
cmd.Parameters.AddWithValue("@phone", br.Phone);
con.Open();
int result = cmd.ExecuteNonQuery();
cmd.Dispose();
return result;
}
catch
{
throw;
}
}
}
}
BALRegister.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BEL;
using DAL;
namespace BAL
{
public class BALRegister
{
DALRegister dr = new DALRegister();
public int SaveUserRegistrationBAL(BELRegister br)
{
try
{
return dr.UserDetails(br);
}
catch (Exception ex)
{
ex.GetType();
}
return 0;
}
}
}
Registration.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BAL;
using BEL;
namespace OnlineExaminationPortal
{
public partial class Registration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
BELRegister objbr = new BELRegister();
BALRegister objbl = new BALRegister();
objbr.Name = TextBox2.Text;
objbr.UserName = TextBox3.Text;
objbr.Password = TextBox4.Text;
objbr.Email = TextBox5.Text;
objbr.Phone = TextBox6.Text;
int value=objbl.SaveUserRegistrationBAL(objbr);
Clear();
if (value == 1)
{
Label1.Text = "Registered Successfully";
}
else
{
Label1.Text = "User Name Not Available.Try With Different User Name";
}
}
public void Clear()
{
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
}
}
}
Please find the error and also let me know , how to move to login page after registration?
<connectionStrings>
<add name="Dbconnection"
connectionString="Server=USER-PC\SHUKLAJI; Database=OnlineExamination; Integrated Security=True"
providerName="System.Data.SqlClient" />