OnItemClick Event not fire in masterpage

2 posts, 0 answers
  1. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 12 Apr 2013 Link to this post

    Hi, I had a dynamic radmenu (using ArrayList) in my masterpage.
    I want to get the DataFieldID when user click the menu item, so i put a OnItemClick event in the code behind, but the event cannot be fire.
    How can I fire the event ? 
    Or is there any other method to get the DataFieldID when user click the item ? thanks.

    My masterpage code as follow:

    <%@ Master Language="VB" CodeFile="LRDB.master.vb" Inherits="LRDB" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head id="Head1" runat="server">
        <asp:ContentPlaceHolder ID="head" runat="server">
        <link href="Style/StyleSheet.css" rel="stylesheet" type="text/css" />
       <form id="form1" runat="server">  
            <telerik:RadScriptManager runat="server" ID="RadScriptManager1"/>
        <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="false" />
                        <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="true"   />
         <div class="div_menu">  
    <telerik:RadMenu ID="RadMenu1" runat="server" EnableRoundedCorners="True" EnableShadows="True" EnableTextHTMLEncoding="True" Skin="Windows7" DataSourceID="ObjectDataSource1" DataFieldID="Function_ID"
    DataFieldParentID="ParentID" DataTextField="Description" DataNavigateUrlField="Page" OnDataBound="RadMenu1_DataBound" OnItemDataBound="RadMenu1_ItemDataBound" Width="100%" OnItemClick="RadMenu1_ItemClick">                         
             <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
                 SelectMethod="GetMenuByFunctionID" TypeName="LRDB">
                     <asp:SessionParameter DefaultValue="" Name="id" SessionField="FID"
                         Type="String" />                    
            <hr  class= "menu_hr" />
             <asp:Label ID="lb_panel" runat="server" Font-Bold="true" ForeColor="#485C7F" Font-Names="Arial"
             <div id="content_function" class="content_function">              
                <div id="content" class="content">
    <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server" ></asp:ContentPlaceHolder>

    VB code behind of the masterpage:

    Imports System
    Imports System.Collections.Generic
    Imports Telerik.Web.UI
    Partial Class LRDB
        Inherits System.Web.UI.MasterPage   
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                Dim UID As String = HttpContext.Current.Session("UserID")
                If Not IsNothing(UID) Then
                    'Generate Menu Bar By UserID, RoleTypeID
                    Dim FID As String = GetFunctionIDByRoleTypeID(GetRoleTypeIDByUserID(UID))
                    HttpContext.Current.Session("FID") = FID
                End If
            End If
        End Sub
        Protected Sub RadMenu1_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles RadMenu1.ItemClick
            Dim SelectFunctionID As Integer = 0
            SelectFunctionID = RadMenu1.SelectedValue
        End Sub
        Protected Sub RadMenu1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
            Me.InsertSeparator(0, Me.RadMenu1)
        End Sub
        Public Sub RadMenu1_ItemDataBound(ByVal sender As Object, ByVal e As RadMenuEventArgs)
            If e.Item.Level = 0 Then           
                Me.InsertSeparator(e.Item.Index + 1, Me.RadMenu1)
            End If
        End Sub
        Private Sub InsertSeparator(ByVal index As Integer, ByVal menu As RadMenu)
            Dim separator As New RadMenuItem()
            separator.IsSeparator = True
            separator.Text = "|"
            menu.Items.Insert(index, separator)
        End Sub
    End Class

    And the Common VB function:

    Public Function GetFunctionIDByRoleTypeID(ByVal id As String) As String
        Dim FID As String = ""
        Dim rList = Split(id, ",")
        Dim dc As New dcLRDBDataContext
        Dim i As Integer = 0
        'Get Dintinct Function ID
        Dim result = (From cs In dc.db_RoleType_AccessRights Where rList.Contains(cs.RoleTypeID) Select cs.FunctionID Order By FunctionID Ascending).Distinct().ToList
        If result.Count > 0 Then
            For i = 0 To result.Count - 1
                FID += result.Item(i).ToString & ","
            FID = result.Item(0).ToString
        End If
        Return FID
    End Function
    Public Function GetRoleTypeIDByUserID(ByVal id As Integer) As String
        Dim RoleType_list As String = ""
        Dim dc As New dcLRDBDataContext
        Dim result = (From cs In dc.db_UserRoles Where cs.UserID = id Select cs.RoleTypeID).ToList
        Dim i As Integer = 0
        If Not IsNothing(result) Then
            If result.Count > 0 Then
                For i = 0 To result.Count - 1
                    RoleType_list += result.Item(i).ToString & ","
                RoleType_list = result.Item(0).ToString
            End If
        End If
        Return RoleType_list
    End Function


  2. Kate
    Kate avatar
    1898 posts

    Posted 18 Apr 2013 Link to this post

    Hello Joe,

    I tested a scenario with a master and content page but I was not able to get the issue that you describe. Attached to this post you can find a simplified version of my testing page. Give it a try and let me know how it goes. I would also suggest that you open a support ticket where you can attach a very simplified version (that includes only the needed code, you can use a dummy data source) of your  project that reproduced the issue that you get so I can test it locally and help you resolve the problematic behavior.

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top