Server side event for asp control within itemtemplate

2 posts, 0 answers
  1. Brad H
    Brad H avatar
    31 posts
    Member since:
    Aug 2009

    Posted 25 Aug 2009 Link to this post

    I have a radMenu with an ItemTemplate in it.  Within that ItemTemplate, I have an asp textbox and  imagebutton comprising a search feature.  How can I get a server side event to fire when that imagebutton is clicked?  I can't seem to access it.  I understand how to access and change properties of controls within ItemTemplate.  But I cannot figure out how to get an event handler.  Here is my code.  Thanks for your help!

    <telerik:RadMenu ID="trmNavSearch" runat="server" Skin="NavSearch" EnableEmbeddedSkins="false" 
            EnableEmbeddedBaseStylesheet="false"
            <Items> 
                <telerik:RadMenuItem runat="server" Width="164px"
                    <ItemTemplate> 
                                <asp:TextBox ID="tbSearch" ValidationGroup="vgSearch" MaxLength="100" 
                                    runat="server" CssClass="textbox"></asp:TextBox> 
                                <asp:ImageButton ValidationGroup="vgSearch" ID="btnSearch" runat="server" 
                                    ImageUrl="~/global/images/green_arrow_submit.png" /> 
                    </ItemTemplate> 
                </telerik:RadMenuItem> 
            </Items> 
        </telerik:RadMenu> 

    This code behind obviously does not work as "btnSearch" is not recognized in the handler.
    Protected Sub btnSearch_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btnSearch.Click 
            Dim myURL As String = "" 
            myURL = myURL & "Search.aspx?SearchTerm=" & trmNavSearch.FindItemByText("tbSearch").Text.Trim & "&I=" 
            Response.Redirect(myURL.ToString) 
        End Sub 



  2. Brad H
    Brad H avatar
    31 posts
    Member since:
    Aug 2009

    Posted 25 Aug 2009 Link to this post

    Nevermind.  I found the answer.  I just needed to assign the Sub in the OnClick property.  Thanks anyway.

    <asp:ImageButton ValidationGroup="vgSearch" ID="btnSearch" runat="server" 
                                    ImageUrl="~/global/images/green_arrow_submit.png" OnClick="btnSearch_Click"/> 

Back to Top