Greetings again,
We use the following code to check whether or not user exists on our database.
Upon the mouse leaving a textbox, if user already exists, a message indicating that user already exists is displayed.
If user does not exist, user gets a "Proceed" message.
This works great.
What we are having problem with right now is that if user exists, we would like the user information (name, title, email, ID) to populate the textboxes upon the mouse leaving the ID textbox.
The code I have so far is not working - it doesn't populate the textboxes after the check.
What am I missing?
We would prefer to NOT create a search box to do this.
Thanks much in advance.
HTML
<td>
<div class="input text">
<label id="lblEmpID"><span style="font-weight:bold;font-size:16px;color:#000000;">Your Id</span><span style="color:#ff0000">*</span></label>
<asp:TextBox ID="txtEmpID" placeholder="Badge ID..." style="width:100px;" class="form-control numeric" runat="server" AutoPostBack="true" ontextchanged="txtEmpID_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredempidValidator1" Font-Bold="true" SetFocusOnError="true" runat="server"
ErrorMessage="*" ControlToValidate="txtEmpID" />
<span class="waitingdiv" id="loadingdiv" style="display:none;"><img src="images/ajax-loader.gif" alt="Loading" />Please wait...</span><br />
</div>
</td>
<td>
<div id="checkusername" runat="server" Visible="false">
<asp:Image ID="imgstatus" runat="server" Width="17px" Height="17px"/>
<asp:Label ID="lblStatus" runat="server"></asp:Label>
</div>
</td>
Code (VB.Net)
Protected Sub txtEmpID_TextChanged(sender As Object, e As EventArgs)
If Not String.IsNullOrEmpty(txtEmpID.Text) Then
Dim Conn As SqlConnection
'Read in connection String
Conn = New SqlConnection(ConfigurationManager.ConnectionStrings("ppmtest").ConnectionString)
Conn.Open()
Dim cmd As New SqlCommand("select * from Employees where EmpID=@empID", Conn)
cmd.Parameters.AddWithValue("@empID", txtEmpID.Text)
Dim dr As SqlDataReader = cmd.ExecuteReader()
If dr.HasRows Then
checkusername.Visible = True
imgstatus.ImageUrl = "images/NotAvailable.jpg"
lblStatus.Text = "You have already signed up"
lblStatus.ForeColor = System.Drawing.Color.Red
System.Threading.Thread.Sleep(100)
'txteName.Text = dr("employeeName").ToString()
'txttitle.Text = dr("empTitle").ToString()
'txtemail.Text = dr("email").ToString()
'txtEmpID.Text = dr("empID").ToString()
Else
checkusername.Visible = True
imgstatus.ImageUrl = "images/Icon_Available.gif"
lblStatus.Text = "Proceed"
System.Threading.Thread.Sleep(100)
End If
Else
checkusername.Visible = False
End If
End Sub