Tapping into a controls event RRS feed

  • Question

  • User-323560177 posted

    Is it possible to tap into a controls prerender event?  For example, if I wanted a SPAN tag to appear around a asp:TextBox control.  Could I somehow hook an event into the control that would still call the controls prerender, but allowing me the determine when it gets called?

    Wednesday, January 27, 2010 5:51 PM

All replies

  • User-455205763 posted

    Sure, jsut create a new class that derives from TextBox and overrides the Render Method. Like this:

    Public Class CustomTextBoxRender
            Inherits System.Web.UI.WebControls.TextBox

            Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

                ' Add custom Render code HERE!!!

                ' Call the base class's Render method.
            End Sub
        End Class

    Wednesday, January 27, 2010 8:28 PM
  • User-323560177 posted

    I really need to do without overriding, on the fly.  Is there a way this could be achieved using delegates?  In a nutshell, I need to somehow force the control to call a new variation of the render method without removing the current Render method it has in place.  I know this sounds odd, but this would be a tremendous help.

    Wednesday, January 27, 2010 8:41 PM