This is a migrated thread and some comments may be shown as answers.

Server side event for asp control within itemtemplate

1 Answer 62 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Brad H
Top achievements
Rank 2
Brad H asked on 25 Aug 2009, 04:23 PM
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 



1 Answer, 1 is accepted

Sort by
0
Brad H
Top achievements
Rank 2
answered on 25 Aug 2009, 06:32 PM
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"/> 

Tags
Menu
Asked by
Brad H
Top achievements
Rank 2
Answers by
Brad H
Top achievements
Rank 2
Share this question
or