Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
A user input a MAWB in a textbox, e.g. 234255.

The number is validated against a database table column (say, MAWB ).

I am using SQL server. The table column [staffID] is from a table (say, MAWB ).

How can I use CustomValidator, a handler to do that? How can I connect to the VIA table and compare the input value against column MAWB ?



If the number matches with one of the records in the database table column, then the textbox pass the validation.


I'm very new to programming. Is there some coding example please.
Posted
Comments
[no name] 19-Feb-13 5:56am    
(40,857 online) plz help me?

1 solution

ASP.NET
<asp:textbox id="txtValidate" runat="server" autopostback="True" xmlns:asp="#unknown">
        ontextchanged="txtValidate_TextChanged" /></asp:textbox>


C#
protected void txtValidate_TextChanged(object sender, EventArgs e)
        {
           string query = "Select * from table where StaffId = " + Convert.ToInt32(txtValidate.Text);
          DataTable dtCount = ExecuteQuery(query);
          if(dtCount.Count > 0)
                true;
          else
                false;
        }



implement code like this. (HTML and Code Behind)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900