473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help with custom event handler

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("Butt on1");

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
Nov 21 '05 #1
3 3415

AddHandler myButton.Click, Addressof MyButtonWasClicked

Then:

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

--
--Zorpie
"vvenk" wrote:
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("Butt on1");

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

Nov 21 '05 #2
"vvenk" <vv***@discussions.microsoft.com> schrieb:
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("Butt on1");

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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
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?
"Herfried K. Wagner [MVP]" wrote:
"vvenk" <vv***@discussions.microsoft.com> schrieb:
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("Butt on1");

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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lamont Adams | last post by:
Hi all, I've created numerous custom controls of varying complexity, but I've been on this problem for a day and a half, and I can't figure this mystery out. I hope one of you kind folks can...
3
by: Chris Newby | last post by:
I have a very simple custom control that derives from WebControls.Panel and implements INamingContainer. It appear that controls created as children of my custom control are having ViewState...
7
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
2
by: tperri | last post by:
I've got a page with a couple ascx files on it. One od the controls displays a user's picture, the other contains a datagrid where a user can upload more pictures, change their default picture,...
7
by: Peter Row | last post by:
Hi, I've started work on my own control some parts of which use standard controls, others I need to draw on my controls surface to get the display output I require, however.... I seem to be...
3
by: bill | last post by:
I am using VS2005 to build a web form dynamically. I'm using AddHandler to connect a custom event handler to the TextChanged event of dynamically added textbox controls. Data entered in the...
3
by: Andy | last post by:
Hi folks, I have a customvalidator control that works properly if it isn't contained in an ASP:TABLE. But, when I place it inside an ASP:TABLE, I find that _ServerValidate doesn't get fired,...
3
by: Rich Squid | last post by:
Hello Here's my basic problem: On my asp.net form page I have a DetailsView (default mode=edit) bound to a AccessDataSource control. Users can successfuly update a databound template field,...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi, I have built a custom control button which inherits from WebControl and implements IPostBackEventHandler. The control also declares an event Click and provides a method OnClick which invokes...
0
by: Jordan S. | last post by:
Using .NET 3.5... in a "plain old" .aspx page I have the following code in the Init event: this.Context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.