Questions tagged [addhandler]

AddHandler (and the companion RemoveHandler) is used to add (and remove) event handlers dynamically in VB.NET

Add and remove event handlers dynamically in .NET

.NET lets you add and remove Event Handlers dynamically on the fly. Your code can start and stop handling events at any time during program execution. Also, you can tie the same code (event handler) to multiple events similar to the Handles clause in VB.NET.

The VB.NET AddHandler and RemoveHandler statements allow this behavior. Both statements take two arguments: the name of the event to handle and the name of the procedure that will handle the event.

93 questions
0
votes
0 answers

Adding MouseOver event to htmlDocument causes a System.NullReferenceException

I have a form with a webBrowser object named "myBrowser". When I open a webpage in this browser, I would like to get the id of any element that my mouse is hovering over and show it in a textbox named "txtProperties". I have tried to achieve this…
paul frith
  • 551
  • 2
  • 4
  • 21
0
votes
1 answer

VB.Net Threading and Addhandler Troubles

Hello again StackOverflow community! I am working on a class "SendLogfileClass". In this class I send a logfile via email to said email account. That part works as intended. What I am having problems with is trying to process the Async Completion…
0
votes
1 answer

Question regarding missing RemoveHandler in WPF application function

We have a few scenarios in our WPF/MVVM application where a window is being instanciated and opened within the confines of a method. Very simplistic example: Private Sub subOpenWindow Dim myViewModel = New Viewmodel1 'create viewmodel that…
Gatmando
  • 2,179
  • 3
  • 29
  • 56
0
votes
0 answers

My dynamically created ImageButtons won't fire up the click event

I need to create a table whose first column is an image button that deletes the whole row when clicked (actually it deletes a database row then reloads the HTML table). The table and the buttons display as expected, but when I click a button,…
0
votes
1 answer

Can't get AddHandler and AddressOf to work with UpdatePanel

I am building a page that dynamically builds UpdatePanels, Panels, DDL, and Buttons. There is a single button for every UpdatePanel. I am doing some testing by trying to change a value after the button is clicked. As I step through the code after a…
Regis
  • 166
  • 4
  • 17
0
votes
1 answer

Why is my event handler firing two times?

I have a bunch of panels that I am adding to a single parent panel and I want to add event listeners to all of the panels but not until after they have all been added to the parent (becuase I don't want the event listeners firing each time a new…
John
  • 1,310
  • 3
  • 32
  • 58
0
votes
1 answer

WithEvents vs AddHandler in VB.Net

I asking myself what the differences are between Dim WithEvents EClass As New EventClass and AddHandler Obj.XEvent, AddressOf Me.XEventHandler In which context you should use the first or the second? Can anyone explain it? Thanks.
H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144
0
votes
1 answer

ASP VB Stuck on Dynamic Controls, Viewstate, and Postback. Could really use some help to get back on track

I've been reading posts and articles and just getting a little confused and consequently burning through time I don't have at the moment Can someone look at my code and tell me where I've gone wrong? Partial Class PayerContacts Inherits…
mreinsmith
  • 154
  • 3
  • 14
0
votes
2 answers

dynamically create a new tab with textbox, button in the tab with click and keypress events (AddHandler is what i cant get to work)

I am creating some tabs and I need two things to work that I can't get to work. I need to AddHandler for a Textbox.Keypress event AND a Button.Click event. I can make these things work outside of the tabcontrol but not in. In the example below my…
Mike
  • 47
  • 7
0
votes
2 answers

OpenShift PHP with .html Extension

As we know, it is easy to get Apache to handle .html pages as PHP pages by adding the following line to http.conf: AddHandler application/x-httpd-php .php .html How can this be done in OpenShift? How can I edit http.conf in OpenShift? Or is there…
Lyndon
  • 573
  • 6
  • 24
0
votes
1 answer

AddHandler is not working

Why is my addhandler not firing? In the Sub "CreateTagStyle", the AddHandler is not firing when the LinkButton is clicked. Is there some reason that addhandlers can't be added at certain points of the page lifecycle? <%@ Page Title="" Language="VB"…
RichC
  • 7,829
  • 21
  • 85
  • 149
0
votes
1 answer

VB.NET AddHandler is creating a new instance of a form. Causing null delegate

This thread was marked as a duplicate becauseI have encountered this problem before and have asked a question before. I would now normally know how to solve it (i.e. by using a variable pointing to an instance of the form instead of its name).…
Daniel
  • 1,399
  • 3
  • 16
  • 29
0
votes
1 answer

Dynamic button - onclick just won't work

I have used this code in a few other projects, but this time I just can't get it to work. I am attempting to track the click event of a button control, but it just isn't firing. I have tried re-loading in the controls in the page.init (I had to…
Benjo
  • 179
  • 1
  • 8
0
votes
2 answers

Using my c# event in VB.NET

I have written a DLL in C#, and I would like to get callback from an event. In C# I dit it the following way: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using…
tmighty
  • 10,734
  • 21
  • 104
  • 218
0
votes
0 answers

create an addhandler with arguments to the handler

I have a C# line of code I want to translate to VB.net It is: job.StateChanged += new EventHandler(StateChanged); I know how to do this: AddHandler job.StateChanged, AddressOf StateChanged But that seems to leave out…