0

I am trying to create a simple WebForm in Visual Studio 2017. I have a textbox and I have to catch "Leave" event on it, but these are the only events available:

Events

I've been searching for similar questions and problems but I did not find any solutions.

Peter B
  • 22,460
  • 5
  • 32
  • 69
nkocev
  • 15
  • 1
  • 1
  • 4
  • Something that just is not there cannot be found, for more see https://stackoverflow.com/questions/5750580/is-there-a-onexit-or-leave-event-on-asp-net-textbox and https://stackoverflow.com/questions/12526429/how-to-get-gotfocus-lostfocus-event-of-a-textbox-in-webforms-using-c-sharp – Peter Bons Feb 24 '18 at 11:02

2 Answers2

0

There is no Leave event because ASP.NET runs on Server while the user's "leave" happens on the client. You could handle the blur event in JavaScript and then do a post back. Very nice solution is in this SO answer.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
0

This is normal behavior, you're working with a System.Web.UI.WebControls.TextBox.

It doesn't have a Leave event since it's a Web UI control. If you want a Leave event, you'll have to use Javascript (note that this will be Client-Side).

Haytam
  • 4,643
  • 2
  • 20
  • 43