Re: Simple composite control fires event fires first time but not second
- From: "William Niver" <thor.niver@xxxxxxxxxxxxx>
- Date: Mon, 11 May 2009 18:55:04 -0500
<ToolboxData("<{0}:TopNavMenuComp runat=server></{0}:TopNavMenuComp>")> _
Public Class TopNavMenuComp
Inherits CompositeControl
Protected Overrides Sub createchildcontrols()
MyBase.Controls.Clear()
Dim _SearchTerm As New TextBox
With _SearchTerm
.ID = "searchtermID"
End With
MyBase.Controls.Add(_SearchTerm)
Dim _GoSearch As New Button
With _GoSearch
.ID = "mysearchID"
.Text = "Go Search"
AddHandler .Click, AddressOf Me.OnSearchClick
End With
MyBase.Controls.Add(_GoSearch)
End Sub
Private Sub OnSearchClick(ByVal sender As Object, ByVal e As System.EventArgs)
Dim _SearchTerm As TextBox = TryCast(Me.FindControl("_SearchTerm"), TextBox)
If _SearchTerm IsNot Nothing Then
Dim buttonclicked As String = _SearchTerm.Text
End If
End Sub
End Class
Hope that helps!
<sellars.paul@xxxxxxxxxxxxxx> wrote in message news:71d82764-f725-44de-a6f1-6c3980879b1c@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,
I have a simple composite control (asp.net 1.1). The on click event
fires the first time the button is clicked but not on subsequest
clicks. Any ideas why please?
Imports System.ComponentModel
Imports System.Collections.Specialized
Imports System.Web.UI
Imports System.Web
Imports System.Web.UI.WebControls
Imports Microsoft.ContentManagement.Common
Imports Microsoft.ContentManagement.Publishing
Imports System.Web.UI.WebControls.WebControl
Imports Microsoft.ContentManagement.WebControls.Design
Imports Microsoft.ContentManagement.WebControls
<ToolboxData("<{0}:TopNavMenuComp runat=server></{0}:TopNavMenuComp>")_Public Class TopNavMenuComp
Inherits Control
Implements INamingContainer
Private _SearchTerm As TextBox
Private _GoSearch As Button
Protected Overrides Sub createchildcontrols()
Controls.Clear()
_GoSearch = New Button
_SearchTerm = New TextBox
_SearchTerm.ID = "searchtermID"
_GoSearch.Text = "Go Search"
_GoSearch.ID = "mysearchID"
With Me.Controls
.Add(_SearchTerm)
.Add(_GoSearch)
End With
AddHandler _GoSearch.Click, New EventHandler(AddressOf
Me.OnSearchClick)
ensurechildcontrols()
End Sub
Private Sub OnSearchClick(ByVal sender As Object, ByVal e As
EventArgs)
Dim buttonclicked As String
buttonclicked = _SearchTerm.Text
End Sub
There is then a render
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
that includes the lines:
_SearchTerm.RenderControl(output)
_GoSearch.RenderControl(output)
Regards,
Paul
.
- Follow-Ups:
- Re: Simple composite control fires event fires first time but not second
- From: sellars . paul
- Re: Simple composite control fires event fires first time but not second
- References:
- Simple composite control fires event fires first time but not second
- From: sellars . paul
- Simple composite control fires event fires first time but not second
- Prev by Date: Simple composite control fires event fires first time but not second
- Next by Date: Re: Simple composite control fires event fires first time but not second
- Previous by thread: Simple composite control fires event fires first time but not second
- Next by thread: Re: Simple composite control fires event fires first time but not second
- Index(es):