Validating textbox in a webform
I am new to webforms but have created a webform that will add a new user to the database after they fill in all necessary fields. That all works. Now what I want to do is when they fill in their unique ID and they click on the add user button, instead of just adding the user, check to see if that user id already exists in the database and if it does message the user that it does exist. So far I have been using labels as my messages using the visibility property. Not sure if that is the correct way or not but I know msgbox dont work with webforms. I have an sql connectin and the sql command setup but not sure what is next. The field SN is the unique ID.
VB Code:
Me.cnAdd = New System.Data.SqlClient.SqlConnection
Me.cmAdd = New System.Data.SqlClient.SqlCommand
'
'cnAdd
'
Me.cnAdd.ConnectionString = "workstation id=""S-KG-CFSCE-2098"";packet size=4096;integrated security=SSPI;data s" & _
"ource=""KG-CFSCE-2B"";persist security info=False;initial catalog=CF98"
'
'cmAdd
'
Me.cmAdd.CommandText = "SELECT SN FROM dbo.ID"
Me.cmAdd.Connection = Me.cnAdd