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

Event Not Firing?

Hi,

I'm writing a class in VB that will (once I get it working) be rolled
up into a DLL for use in all our web applications. However I'm
running into problems with button events not firing.

Essentially, my (trimmed-down) code contains this:

Public Class ModalDialog
Protected WithEvents btnYes As New Button

Public Event ButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)

Private Sub btnClick(ByVal sender As Object, ByVal e As
System.EventArgs)
RaiseEvent ButtonClick(sender, e)
End Sub

Public Sub SomeSubThatIKnowIsFiring()
AddHandler btnYes.Click, AddressOf btnClick
End Sub
End Class

Then, within the actual page code-behind, I have the following:

Partial Public Class _Default
Inherits System.Web.UI.Page

Dim MD As New ModalDialog

Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
AddHandler MD.ButtonClick, AddressOf GetButtonClick
MyBase.OnInit(e)
End Sub

Protected Sub GetButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim btn As Button = DirectCast(sender, Button)
Msg.InnerHtml = btn.CommandName
End Sub
End Class

In the course of my playing around, I've found that although
ModalDialog.SomeSubThatIKnowIsFiring does indeed fire (as the name
implies), the btnClick sub (which should be raising the event) never
actually executes when I click the button.

I know this code (or its equivalent) should work in Windows
development, but this is my first foray into trying to handle custom
events within a web application. Could somebody point out what I'm
doing wrong, or provide a link to a good guide to handling custom
events, and persisting them upward from within a class up to the page
level?

Regards,
Don Q.

Oct 17 '07 #1
1 1465
is the button added to the page? do you see it render? in asp.net
controls use a round about method to raise events.

the user clicks the button, the browser posts the from to the server,
the server creates a new page instance, and fire the page cycle events,
if the control that performed the postback get notified it caused the
postback. it then raises the correct postback event (say onclick).

-- bruce (sqlwork.com)

Don Q. wrote:
Hi,

I'm writing a class in VB that will (once I get it working) be rolled
up into a DLL for use in all our web applications. However I'm
running into problems with button events not firing.

Essentially, my (trimmed-down) code contains this:

Public Class ModalDialog
Protected WithEvents btnYes As New Button

Public Event ButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)

Private Sub btnClick(ByVal sender As Object, ByVal e As
System.EventArgs)
RaiseEvent ButtonClick(sender, e)
End Sub

Public Sub SomeSubThatIKnowIsFiring()
AddHandler btnYes.Click, AddressOf btnClick
End Sub
End Class

Then, within the actual page code-behind, I have the following:

Partial Public Class _Default
Inherits System.Web.UI.Page

Dim MD As New ModalDialog

Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
AddHandler MD.ButtonClick, AddressOf GetButtonClick
MyBase.OnInit(e)
End Sub

Protected Sub GetButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim btn As Button = DirectCast(sender, Button)
Msg.InnerHtml = btn.CommandName
End Sub
End Class

In the course of my playing around, I've found that although
ModalDialog.SomeSubThatIKnowIsFiring does indeed fire (as the name
implies), the btnClick sub (which should be raising the event) never
actually executes when I click the button.

I know this code (or its equivalent) should work in Windows
development, but this is my first foray into trying to handle custom
events within a web application. Could somebody point out what I'm
doing wrong, or provide a link to a good guide to handling custom
events, and persisting them upward from within a class up to the page
level?

Regards,
Don Q.
Oct 18 '07 #2

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

Similar topics

2
by: Pete | last post by:
I have some funky form/event behavior. Access 97. Split frontend/backend, using Access security. I have the same behavior (or lack of behavior) for the pag_Click() event of two separate pages...
13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
0
by: Ram | last post by:
I have a start page for my application default.htm which contains four frames. header.htm login.aspx rightside.htm footer.htm login.aspx conatins username, password fields and login button....
3
by: Brett | last post by:
I'm using a third part component in a certain app. The component has methods and events. I noticed one particular event was not firing after a while but it should have been. The problem was the...
1
by: Diana | last post by:
I've got a database that has been working successfully for a number of years now. I just added a new item - basically a field that becomes visible depending on another field's value. When I was...
4
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my...
5
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the...
6
by: sjoshi | last post by:
I have a derived class OraBackup which has a method that calls stored procedure on Oracledb to get status of backup job. Now the base class publishes an event like this: public delegate void...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
1
by: bigijoseph | last post by:
Please help : page load event is not firing. -------------------------------------------------------------------------------- Hi, I am a new to .net. I am trying to learn it. I tried the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.