Web control button event not firing

NTurnbullJr

New member
Joined
Nov 29, 2005
Messages
1
Location
Jacksonville, FL
Programming Experience
10+
When I place a stop at btnDropdown_Click, the debugger doesn’t stop there. So I am assuming the event is not firing when I click the button. How do I get it to fire?

Here is the code for the control.

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls

'<DefaultProperty("Text"), ToolboxData("<{0}:CalendarDropdown runat=server></{0}:CalendarDropdown>")>
Public Class DCHD_CalendarDropdown
Inherits System.Web.UI.WebControls.WebControl

Dim _text As String
WithEvents txtDate As New TextBox
WithEvents btnDropdown As New Button
WithEvents calCalendar As New Calendar

<Bindable(True), Category("Appearance"), DefaultValue("")> Property [Text]() As String
Get
Return _text
End Get

Set(ByVal Value As String)
_text = Value
End Set
End Property
'Create control's appearance
Protected Overrides Sub CreateChildControls()
'Add the sub controls to this composite control
txtDate.Text = _text
Controls.Add(txtDate)
Controls.Add(btnDropdown)
'calCalendar.Style.Item("ZOrder") = 0
Controls.Add(calCalendar)
calCalendar.Visible = False

End Sub
Private Sub btnDropdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDropdown.Click
If calCalendar.Visible Then
calCalendar.Visible = False
Else
calCalendar.Visible = True
End If
End Sub

End Class
 
I don't know exactly what you mean but this code works flawless here:
VB.NET:
[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Button1.Click
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] calCalendar.Visible = [/SIZE][SIZE=2][COLOR=#0000ff]True [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]calCalendar.Visible = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=2]calCalendar.Visible = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]


Regards ;)
 
When you place controls, like buttons, dynamically onto the web page you can not handle the event w/a 'handles Button.click' sub. I capture the OnBubbleEvent and look for the control ID that I want to handle. After handling the event return true or else the event will continue to be bubbled up the control tree.

I tried doing AddHandler but that didn't work either... this was in ASP.NET 1.1. The only thing I could get to work was OnBubbleEvent
 
Back
Top