I want to use On Blur event in my project. but it doesn't work. this is my code:
code c#:
protected void xx()
{
TextBox2.Text = "zzzzzzzzzzzzzzzzzzz";
}
code design:
<asp:TextBox ID="TextBox1" runat="server" onblur="xx"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox>
what is wrong?
by the way, I use visual studio 2010.
**aspx code:**
<asp:TextBox ID="TextBox1" runat="server" onblur="validate();"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox>
**javascript-code:**
function validate()
{
var _textbox = $(this);
$.ajax({
url: "your page url here"(index.aspx) + "?FuncName=ValidateUserid&text="+_textbox.val(),
context: document.body
}).done(function() {
alert("you can do whatever you want here");
});
}
**aspx.cs code (server-side)**
protected void Page_Load()
{
if(Request.QueryString["FuncName"].Equal("ValidateUserid"))
{
string UserId = Request.QueryString["text"];
//Put your database logic here.
}
}
Dont forget to include your Jquery library in HEAD section of your ASPX page.