|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Simple composite control fires event fires first time but not secondI 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 TopNavMenuCompInherits 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 <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.p***@googlemail.com> wrote in message Show quoteHide quote news:71d82764-f725-44de-a6f1-6c3980879b1c@o30g2000vbc.googlegroups.com... > 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 > Hello William,
Thank you for the response. The problem is that the on click event is not firing. The control is for a search box that can be dropped onto every page, when a search term is supplied there is a redirect to the search page (where we use google mini to do the search). The first time I start the application it behaves as I would expect - the OnSearchClick sub happens. I then click the button a second time and it does not happen. I see your code inhertits from compositecontrol. I think this is asp.net 2.0, unfortunately we are still on asp.net 1.1. Regards, Paul Hello,
Found cause of problem. The page on which the control was placed had cacheing turned on: <%@ Outputcache duration="300" location="server" varybyparam="none" varybycustom="cmsposting"%> When I turned off the caching it worked fine. Paul On 12 May, 09:54, sellars.p***@googlemail.com wrote: Show quoteHide quote > Hello William, > > Thank you for the response. The problem is that the on click event is > not firing. The control is for a search box that can be dropped onto > every page, when a search term is supplied there is a redirect to the > search page (where we use google mini to do the search). The first > time I start the application it behaves as I would expect - the > OnSearchClick sub happens. I then click the button a second time and > it does not happen. > > I see your code inhertits from compositecontrol. I think this is > asp.net 2.0, unfortunately we are still on asp.net 1.1. > > Regards, > Paul
Other interesting topics
Wizard Control - Issue 2
Wizard Control Wizard Next Button viewing xml ASP.NET equivelant for include files that won't cause problems Re: ImageUrlEditor - why can't i find it? Re: ImageUrlEditor - why can't i find it? RE: ClientIds for individual CheckBoxes in a CheckBoxList RE: ajax tab container control SetDisplayMode() equivalent in ASP.NET ReportViewer!!! |
|||||||||||||||||||||||