Search code examples
vb.netwebformstextboxclickevent-handling

Textbox click event in vb.net


I am trying to write an onclick event for textbox but VB.net does not seem to support textbox1.click()

I want to open a new form every time someone clicks on the textbox. Opening a new form is no problem, but I cant detect the click. Is there any event for textbox that detects click event?
I saw something like TextboxBase that has Click but I am able to use it well.

please help!

This is how my class looks :
Partial Public Class TextBoxClick Inherits System.Web.UI.Page

End Class

It has some basic load and init events.

I am trying to write a Sub like this :
Private Sub incident_clicked(ByVal sender As Object, ByVal e As System.EventArgs) Handles Incident.OnClick

Incident.Click does not work either.

I am guessing I need to import some class to access the Click event but I am not sure which.

Thanks is advance


Solution

  • TextBox has a Click event, using it is no problem. Your Handles clause however uses OnClick, that's not a valid event name. Do make sure this Sub is inside a Form class and not a module.

    Public Class Form1
        Private Sub TextBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Click
            MessageBox.Show("Click!")
        End Sub
    End Class