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

PanelBar button click help, serverside

1 Answer 61 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
RageMonkeyRage
Top achievements
Rank 1
RageMonkeyRage asked on 26 Aug 2010, 08:18 PM
I have a page which is based on a master page.  On this page I have placed a panel bar.  Inside a panel,  I have a button.  After going through the forums, I have found that

 

 

 

Private Sub RadPanelBar1_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs) Handles RadPanelBar1.ItemClick

 

 

Dim ItemClicked As Telerik.Web.UI.RadPanelItem = e.Item

 

Response.Write(

"Server event raised -- you clicked: " + ItemClicked.Text)

 

 

End Sub

 

Should fire when the button is clicked (unless I misunderstood something).  It doesn't; it reloads the masterpage. Please help as I am lost as to why I cannot capture this.  Also Note that I want to do everything server side, unless impossible to do so, which is the exception in my application.  Here is some simplified code to Illustrate my issue:

 

 

 

 

 

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Pages/WorkPlanProject.Master" CodeBehind="TestButtonInPanel.aspx.vb" Inherits="WQS_Presentation.TestButtonInPanel" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server">
        <Items>
            <telerik:RadPanelItem runat="server" Text="Root">
            <ItemTemplate><asp:Button ID="button" runat="server" /></ItemTemplate>
            </telerik:RadPanelItem>
        </Items>
    </telerik:RadPanelBar>
</asp:Content>

And the code behind:

Public Partial Class TestButtonInPanel
    Inherits System.Web.UI.Page
  
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
    End Sub
  
    Private Sub RadPanelBar1_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs) Handles RadPanelBar1.ItemClick
        Dim ItemClicked As Telerik.Web.UI.RadPanelItem = e.Item
        Response.Write("Server event raised -- you clicked: " + ItemClicked.Text)
    End Sub
End Class

This code never fires - the master page is reloading when the button gets clicked.  What is the correct way to do this (serverside)?

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 27 Aug 2010, 01:10 PM
Hello Peter,

ItemClick event is not fired, because there is an item template in "Root" item. You should either subscribe to OnClick event of the button:

<telerik:RadPanelBar ID="RadPanelBar1" runat="server">
    <Items>
        <telerik:RadPanelItem runat="server" Text="Root">
            <ItemTemplate>
                <asp:Button ID="button" runat="server" OnClick="button_click" /></ItemTemplate>
        </telerik:RadPanelItem>
    </Items>
</telerik:RadPanelBar>

or use ContentTemplate instead (please note that it's available since Q2 2010 release):

<telerik:RadPanelBar ID="RadPanelBar1" runat="server">
    <Items>
        <telerik:RadPanelItem runat="server" Text="Root">
            <ContentTemplate>
                    <asp:Button ID="button" runat="server" ></ContentTemplate>
        </telerik:RadPanelItem>
    </Items>
</telerik:RadPanelBar>

- in this case ItemClick event will be fired when "Root" is clicked.

Regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
PanelBar
Asked by
RageMonkeyRage
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or