M
Matthew Judd
I have written a template control which contains a button. I have added a
public event to the control which I raise on the button's Click event. In the
main page that contains an instance of this template control I have code in
the codebehind page to handle this event. My problem is that this code never
fires and in fact the form validation controls don't respond when I click the
button either. Here are some code snippets:
-This is the start of my template control:
<ToolboxData("<{0}:TableTemplate runat=server></{0}:TableTemplate>")> Public
Class TableTemplate
Inherits System.Web.UI.WebControls.WebControl
Implements INamingContainer
Public Event Submit(ByVal Sender As Object, ByVal e As System.EventArgs)
Private WithEvents m_Submit As New Button
Private Sub m_Submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles m_Submit.Click
RaiseEvent Submit(Me, EventArgs.Empty)
End Sub
- Then in the code behind of my containing page:
Public Class NewProject
Inherits System.Web.UI.Page
Protected WithEvents TableTemplate1 As TableTemplate.TableTemplate
Private Sub TableTemplate1_Submit(ByVal Sender As Object, ByVal e As
System.EventArgs) Handles TableTemplate1.Submit
Response.Write("Clicked")
Response.End
End Sub
---
I have tried this several different ways and I have not been able to get
this to work. Does anybody have any idea what I am doing wrong?
Thanks.
Matthew Judd
public event to the control which I raise on the button's Click event. In the
main page that contains an instance of this template control I have code in
the codebehind page to handle this event. My problem is that this code never
fires and in fact the form validation controls don't respond when I click the
button either. Here are some code snippets:
-This is the start of my template control:
<ToolboxData("<{0}:TableTemplate runat=server></{0}:TableTemplate>")> Public
Class TableTemplate
Inherits System.Web.UI.WebControls.WebControl
Implements INamingContainer
Public Event Submit(ByVal Sender As Object, ByVal e As System.EventArgs)
Private WithEvents m_Submit As New Button
Private Sub m_Submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles m_Submit.Click
RaiseEvent Submit(Me, EventArgs.Empty)
End Sub
- Then in the code behind of my containing page:
Public Class NewProject
Inherits System.Web.UI.Page
Protected WithEvents TableTemplate1 As TableTemplate.TableTemplate
Private Sub TableTemplate1_Submit(ByVal Sender As Object, ByVal e As
System.EventArgs) Handles TableTemplate1.Submit
Response.Write("Clicked")
Response.End
End Sub
---
I have tried this several different ways and I have not been able to get
this to work. Does anybody have any idea what I am doing wrong?
Thanks.
Matthew Judd