How to handle this event?

2

234

I have a button for which I want to handle the click event. Here is my
setup:

The base page, simplified for discussion:
=================================

Public Class clsBasePage
Inherits System.Web.UI.Page

Public objForm As New HtmlForm
Public anHTMLTextWriter as HTMLTextWriter
_________________________________

Private Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Init

With objForm
.Enctype = "application/x-www-form-urlencoded"
.EnableViewState = True
.ID = "frmForm"
End With

Me.Controls.Add(objForm)

End Sub

End Class

=================================

During the base page's render event, anHTMLTextWriter is assigned to the
exposed html text writer.

Here's a simplified example of the derived page I'm working with:

=================================

Public Class myDerivedPage
Inherits clsBasePage

Private txtName As New TextBox
Protected WithEvents btnSave As New Button
_________________________________

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

With Me.objForm
.Controls.Add(Me.txtName)
.Controls.Add(Me.btnSave)
.RenderControl(Me.anHTMLTextWriter)
End With

End Sub
_________________________________

Public Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click

Response.Write("btnSave.Click<br>")

End Sub

End Class

=================================

Other than the directive statement <%@ Page Language="vb"... etc, the .aspx
file of both the derived and base page have no content.

If I run this project, surf to the derived page and click the 'save' button,
it triggers a postback but the btnSave_Click routine is never called. I
have tried using an HTMLButton object, instead of a Button object, and
handling the .ServerClick event. I've tried AddHandler to implicitly define
a handler, but I have no success in consuming the Click and/or ServerClick
events (depending on which button object is used).

I feel I am missing something fundamental here, can someone point me in the
right direction? TIA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,229
Latest member
GloryAngul

Latest Threads

Top