First explain the two attributes,
The AutoPostBack property is used to set or return whether an automatic upload to the server occurs when the user presses the Enter or Tab key in a TextBox control.
If this property is set to TRUE, Auto-callback is enabled, otherwise FALSE. The default is FALSE.
OnTextChanged: A thing that loses focus can start an event
<asp:textbox id= "Txttitle" runat= "Server" width= "400px" validationgroup= "Add"
Maxlength= "autopostback=" true "ontextchanged=" txttitle_textchanged "></asp:TextBox>
<b><asp:label id= "lblmessage" runat= "Server" text= "" ></asp:Label></b>
protected void Txttitle_textchanged (object sender, EventArgs e)
{
bool result = Checktitle (TxtTitle.Text.Trim ());
if (result = = True)
{
Lblmessage.text = "can be used! ";
}
if (result = = False)
{
lblmessage.text = "title already exists";
}
}
public static bool Checktitle (string title)
{
DataTable dt = DB. Getdatatable ("S_title", "Table1", "s_title=" "+title+" ' "," ");
if (dt. Rows.Count > 0)
{
return false;
}
Else
return true;
}
Among them, the key here is autopostback= "true", if not, it will not be implemented validation
Verify that the title exists (TextBox control loses focus validation)