Validator with already exist username

Posted by Nerdanalysis under ASP.NET on 3/25/2012 | Points: 10 | Views : 4033 | Status : [Member] | Replies : 4
Hi,

I am made a webpage and wrote a function to check weather the user is available or not. Once the user would click submit. if the user is already exist, I want to show the error infront of the textbox. I kind a have an idea that it will be done by custom validations asp.net control. But i dont know where to write the code and where to call that.

Kind regards
Nerd




Responses

Posted by: Self-Innovator on: 3/25/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi..Nerad try wit this link
http://www.dotnetfunda.com/codes/code1857-validating-duplicate-email-id-from-database-while-form-filling.aspx

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Nerdanalysis, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nerdanalysis on: 3/26/2012 [Member] Starter | Points: 25

Up
0
Down
Cheers self-innovator...but how to get that error infront of text box like other validators....

Nerdanalysis, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 5/23/2012 [Member] Starter | Points: 25

Up
0
Down
protected void txtUsername_TextChanged(object sender, EventArgs e)

{
if (!string.IsNullOrEmpty(txtUsername.Text))
{
SqlConnection con = new SqlConnection("Data Source=CONNECTIONSTRNG");
con.Open();
SqlCommand cmd = new SqlCommand("select * from UserInformation where UserName=@Name", con);
cmd.Parameters.AddWithValue("@Name", txtUsername.Text);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
checkusername.Visible = true;

lblStatus.Text = "UserName Already Taken";
}
else
{
checkusername.Visible = true;

lblStatus.Text = "UserName Available";
}
}
else
{
checkusername.Visible = false;
}
}


REGARDS


sriram

Nerdanalysis, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 6/8/2012 [Member] Starter | Points: 25

Up
0
Down
http://sandeep-chourasia.blogspot.in/2012/05/check-exist-or-not.html

Better to use like this then using in sp.

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Nerdanalysis, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response