How to Check

Y

Yoshitha

In my webform i have 2 textbox

controls and one button control.
in 1st textbox control i'll enter

email id when it lost its focus i've

tocheck whether the entered email id

exist in database or not, if exists

it has to dispay message that email

id already exist
and i want to set focus to that text box.

see the below code


Private Sub txtEmail_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtEmail.TextChanged

Dim i As Byte

Dim cmd As New OleDbCommand

cmd.Connection = MyConn

cmd.CommandText = "Select count(*) from QA_UserType where Email_Id='" &
txtEmail.Text & "'"

i = cmd.ExecuteScalar()

If i <> 0 Then

Response.Write(txtEmail.Text & " already exist")

txtEmail.Text = ""

// how to set focus to this text box. //

End If

End Sub

Private Sub txtEmail_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtEmail.TextChanged

Dim i As Byte

Dim cmd As New OleDbCommand

cmd.Connection = MyConn

cmd.CommandText = "Select count(*) from QA_UserType where Email_Id='" &
txtEmail.Text & "'"

i = cmd.ExecuteScalar()

If i <> 0 Then

Response.Write(txtEmail.Text & " already exist")

txtEmail.Text = ""

End If

End Sub



when am running my application am

getting that message after clicking

on submit button. but what i want is
Hi,
it has to check before clicking on

submit button.
I set postback property of text box to true.

thanx in advance
yoshitha
 
G

Guest

Just setting the autopostback property of the textbox should actually work.
This results in a postback as soon as the value of the textbox is changed and
the textbox loses focus.

Kind regards,
Nikander & Margriet Bruggeman
 
Y

Yoshitha

hi
i've one more problem

i've to enter email id in text box so when am entering the email id the
textchanged event is firing.
but when i enter first charcter in the text box , the email ids statrs with
that character are displaying in the text box, so when i select that email
id, it is displaying in that text box but it not firing the textchaged event
of text box and also if i obseve the length of this text box it is
displaying 0 .
why this is happening with my application.
can u tell me
thanx in advance
yoshitha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top