Search code examples
asp.nettextboxalertonfocus

I need to give an alert when the user places the cursor in a textbox in asp.net. How do I go about doing this?


I need to give a custom alert to the user when the user places the cursor in a textbox item in asp.net. How do I go about doing this? Please help.


Solution

  • Javascript on focus event.

    On Page_Load or Page_Init method add this code:

     mytextBox.Attributes.Add("onfocus", "enterTextBox();")
    

    Then on the page add a script tag with this :

    function enterTextBox() {
         alert('hello');
    }