C
chambersdon
I have a webControl that extends the dataGrid with a button added.
When this butotn is clicked I don't get the clicked event. I've
removed almost all the code and I'm down to a very basic example.
I've made similar controls in the past and have never had this problem.
In fact, the code below is almost an exact copy of code that works
when extending a textBox. I'm probably over looking something very
simple.
Here is my class:
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
<DefaultProperty("Text"), ToolboxData("<{0}:AutoDataGrid
runat=server></{0}:AutoDataGrid>")> Public Class AutoDataGrid
Inherits System.Web.UI.WebControls.DataGrid
Protected WithEvents someBtn As
System.Web.UI.WebControls.ImageButton
Protected Overrides Sub CreateChildControls()
someBtn = New ImageButton
Me.Controls.Add(someBtn)
End Sub
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
ensurechildcontrols()
someBtn.RenderControl(writer)
MyBase.Render(writer)
End Sub
Private Sub someBtn_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles someBtn.Click
Dim i As Integer
i = 5
End Sub
End Class
When this butotn is clicked I don't get the clicked event. I've
removed almost all the code and I'm down to a very basic example.
I've made similar controls in the past and have never had this problem.
In fact, the code below is almost an exact copy of code that works
when extending a textBox. I'm probably over looking something very
simple.
Here is my class:
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
<DefaultProperty("Text"), ToolboxData("<{0}:AutoDataGrid
runat=server></{0}:AutoDataGrid>")> Public Class AutoDataGrid
Inherits System.Web.UI.WebControls.DataGrid
Protected WithEvents someBtn As
System.Web.UI.WebControls.ImageButton
Protected Overrides Sub CreateChildControls()
someBtn = New ImageButton
Me.Controls.Add(someBtn)
End Sub
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
ensurechildcontrols()
someBtn.RenderControl(writer)
MyBase.Render(writer)
End Sub
Private Sub someBtn_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles someBtn.Click
Dim i As Integer
i = 5
End Sub
End Class