Help with custom event handler

G

Guest

Hello:

I came across the following code in C# that adds a custom event handler for
triggering the click event on a button:

System.Web.UI.WebControls.Button button;
object buttonOnTab1 = this.UltraWebTab1.Tabs.GetTab(0).FindControl("Button1");

if(buttonOnTab1 != null)
{
button = (System.Web.UI.WebControls.Button)buttonOnTab1;
button.Click += new System.EventHandler(this.ButtonOnTab1Clicked);
}

Can somebody tell me how this code can be re-written using VB.Net?

Thanks.

Venki
 
G

Guest

AddHandler myButton.Click, Addressof MyButtonWasClicked

Then:

Sub MyButtonWasClicked(sender as object, e as eventargs)
'do some stuff here
End Sub
 
H

Herfried K. Wagner [MVP]

vvenk said:
I came across the following code in C# that adds a custom event handler
for
triggering the click event on a button:

System.Web.UI.WebControls.Button button;
object buttonOnTab1 =
this.UltraWebTab1.Tabs.GetTab(0).FindControl("Button1");

if(buttonOnTab1 != null)
{
button = (System.Web.UI.WebControls.Button)buttonOnTab1;
button.Click += new System.EventHandler(this.ButtonOnTab1Clicked);
}

Can somebody tell me how this code can be re-written using VB.Net?

\\\
AddHandler m_Button1.Click, AddressOf Me.Button1_Click
///
 
G

Guest

Herfried:

Thanks.

This is a ASP.NET application that uses UltraWebTab from Infragistics. One
of the tabs contains a textbox that I want to trap the TextChanged event.

This is what I have:

I tried to do the same thing in vb.ne but it does not work.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim txt As TextBox
Dim button As New Button

txt = Me.uwtMain.FindControl("tbxLong") 'this is the textbox that I am
tried to trap the TextChanged event

If Not txt Is Nothing Then
AddHandler txt.TextChanged, AddressOf Me.tbxLong_Clicked
End If
End Sub

Private Sub tbxLong_Clicked(ByVal sender As Object, ByVal e As
System.EventArgs)
lblRecords.Text = "Do you see this?"
End Sub

When I run the application, the object lnlRecords.Text does not change. The
control does not even pass into this subroutine.

What am I doing wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top