Chris
Chris

Reputation: 7621

Firing event when TextBox is blank

I need to fire an event when a TextBox in ASP.NET has been defocused - I currently handle the TextChanged event for this, but this obviously doesn't fire if they don't type into the box and then defocus. Can I do this?

EDIT: To clarify, I want to fire a server side event - not client side

Upvotes: 1

Views: 278

Answers (1)

Curtis
Curtis

Reputation: 103388

$('input').blur(function() {
   if ($(this).val() == ''){
      __doPostback('MyMethod')
   }
});

protected void MyMethod()...

Upvotes: 4

Related Questions