Cannot reference radschedulercontextmenu

3 posts, 1 answers
  1. Toxic
    Toxic avatar
    20 posts
    Member since:
    Apr 2011

    Posted 18 Jul 2011 Link to this post

    HELP, this is driving me mad!

    I am setting security for controls on an asp.net page from the names in a database. This has worked for eveything so far.....

    For example for Radcontextmenus I use :

    Dim currentitem As Telerik.Web.UI.RadContextMenu = thisform.FindControl(reader("objectname"))
    currentitem.Items(reader("objectindex")).Enabled = reader("permissionvalue")
    currentitem.Items(reader("objectindex")).Visible = reader("visiblevalue")

    For each element in a Context menu.

    However, whenever I reference a RadSchedulerContextMenu the object can never be found. Despite being able to reference it directly through vb.net.

    I have :
    Dim currentitem As Telerik.Web.UI.RadSchedulerContextMenu = thisform.FindControl(reader("objectname"))
    currentitem.Items(reader("objectindex")).Enabled = reader("permissionvalue")
    currentitem.Items(reader("objectindex")).Visible = reader("visiblevalue")

    The same but it doesn't find the object. Whereas if I specifically use the objectname in vb eg. radschedulercontextmenu1.items(0).enabled = false it works.

    Why does the radschedulercontextmenu differ from the radcontextmenu and how should I reference it correctly? Do I need to do so from the radscheduler container?

    Any help much appreciated. Its been a long long day :)

  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 20 Jul 2011 Link to this post

    Hello Toxic,

    Please, try the following code and let me know if it helped  you achieve your goal.
    <telerik:RadScheduler runat="server" ID="RadScheduler1">
           <TimeSlotContextMenus>
               <telerik:RadSchedulerContextMenu ID="SchedulerTimeSlotContextMenu" runat="server">
                   <Items>
                       <telerik:RadMenuItem Text="New Appointment" Value="CommandAddAppointment" />
                       <telerik:RadMenuItem Text="New All Day Event" />
                       <telerik:RadMenuItem IsSeparator="True" />
                       <telerik:RadMenuItem Text="New Recurring Appointment" Value="CommandAddRecurringAppointment" />
                       <telerik:RadMenuItem Text="New Recurring Event" />
                       <telerik:RadMenuItem IsSeparator="True" />
                       <telerik:RadMenuItem Text="Go to today" Value="CommandGoToToday" />
                       <telerik:RadMenuItem Text="Show 24 hours..." Value="CommandShow24Hours" />
                   </Items>
               </telerik:RadSchedulerContextMenu>
           </TimeSlotContextMenus>
           <AppointmentContextMenus>
               <telerik:RadSchedulerContextMenu runat="server" ID="ContextMenu1">
                   <Items>
                       <telerik:RadMenuItem Text="Open" Value="CommandEdit" />
                       <telerik:RadMenuItem IsSeparator="True" />
                       <telerik:RadMenuItem Text="Categorize">
                           <Items>
                               <telerik:RadMenuItem Text="Development" Value="1" />
                               <telerik:RadMenuItem Text="Marketing" Value="2" />
                               <telerik:RadMenuItem Text="Personal" Value="3" />
                               <telerik:RadMenuItem Text="Work" Value="4" />
                           </Items>
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem IsSeparator="True" />
                       <telerik:RadMenuItem Text="Delete" Value="CommandDelete" />
                   </Items>
               </telerik:RadSchedulerContextMenu>
           </AppointmentContextMenus>
       </telerik:RadScheduler>


    Protected Sub Page_Load(sender As Object, e As EventArgs)
        If Not IsPostBack Then
            'Find timeslot context menu by index:
            RadScheduler1.TimeSlotContextMenus(0).Items.Add(New RadMenuItem("test item"))
     
            'Find appointment context menu by id:
            Dim appcm As RadContextMenu = TryCast(RadScheduler1.FindControl("ContextMenu1"), RadContextMenu)
            appcm.Items.Add(New RadMenuItem("test item"))
        End If
    End Sub


    All the best,
    Peter
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Toxic
    Toxic avatar
    20 posts
    Member since:
    Apr 2011

    Posted 21 Jul 2011 Link to this post

    Excellent. Thanks, it works perfectly.
Back to Top