473,396 Members | 2,010 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,396 software developers and data experts.

Attaching an event handler

I am creating a LinkLabel control at runtime. How do I attach an event
handler to it?

Where's the delegate for the OnClick event? I see an OnLinkClicked
delegate but since it is protected, it won't let me set it to the
address of my own handler.

Do I have to inherit every control just because I want to create it
dynamically at runtime?

Bottomline: If I've created a control at runtime, how do I attach my
own event handler to it. I mean, I know the syntax but I see that the
delegates are all "protected."

Nov 21 '05 #1
5 1326
"Water Cooler v2" <wt*****@yahoo.com> schrieb;
I am creating a LinkLabel control at runtime. How do I attach an event
handler to it?


Take a look at the 'AddHandler' statement.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2
oh yeah! I completely forgot. Thanks.

Nov 21 '05 #3
ok, how out of curiosity. If this was C# I was coding in, there's no
AddHandler there, so I believe the only way to do it would be to pass
the name (which is actually the address) of my own handler to the
delegate instancen member inside the control class. Since all these
delegate instance members are protected, would there have been a way to
do it in C# that did not involve inheriting from the control?

Nov 21 '05 #4
"Water Cooler v2" <wt*****@yahoo.com> schrieb:
ok, how out of curiosity. If this was C# I was coding in, there's no
AddHandler there, so I believe the only way to do it would be to pass
the name (which is actually the address) of my own handler to the
delegate instancen member inside the control class. Since all these
delegate instance members are protected, would there have been a way to
do it in C# that did not involve inheriting from the control?


You don't need to inherit in order to be able to add a handler.

\\\
this.Button1.Click += new System.EventHandler(this.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 #5
Water Cooler v2 wrote:
I am creating a LinkLabel control at runtime. How do I attach an event
handler to it?
Use the AddHandler statement

Where's the delegate for the OnClick event? I see an OnLinkClicked
delegate but since it is protected, it won't let me set it to the
address of my own handler.


If you are creating the control at runtime, you need to attach to the
LinkClicked event, not OnLinkClicked.

Nov 21 '05 #6

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

Similar topics

6
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the...
1
by: Toby Miller | last post by:
I have this form validation that I'm trying to build, but it's not working properly. A dynamic function to the onsubmit event for a form. the result of that function (true/false) should then be...
5
by: nukiboy | last post by:
========= test.js =================== function Test() { this.temp = "hehehehe" ; this.method1 = method1 ;
3
by: Cowboy \(Gregory A. Beamer\) | last post by:
I have a user control that has a group of links. It is included on every page of a web application. Some of the pages are forms, and the requirements state "if any of the data has changed, you must...
3
by: Charlie | last post by:
Hi: I would like to attach client side code to an imagebutton that is rendered in a Reapeater control. The client code will simply confirm if users wants to continue with an operation. In this...
6
by: Daz | last post by:
Hello everyone, I would like to open a child window from the parent, and add an onload event listener to the child window which will tell the parent when the document has loaded. As far as I...
1
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I have attached a handler to ServerValidate event. But it does not get called any at all. I have placed breakpoints inside the function, but nothing happens. The ServerValidate event is in an...
2
by: hharry | last post by:
Hello All, In VS 2003, I was able to add event handlers in the InitializeComponent function. In VS 2005, I can no longer see the auto- generated code. I tried to add the event handler for a...
5
by: debrief | last post by:
Hello, I have been trying to hide objects on the onclick event and it works fine in Firefox however IE does not respond at all. Is there a way around this? I have the following in my...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.