Disable Context Menu.

2 posts, 0 answers
  1. Timothy Kruszewski
    Timothy Kruszewski avatar
    76 posts
    Member since:
    Feb 2010

    Posted 10 Jan 2011 Link to this post

    For security reasons I need to disable the right click option for the context menus but have been unsuccessful with the code samples I've used.  I've tried to disable it via client side scripting and server side scripting and neither option has worked.  If there is a server side solution for this could you please point me in the right direction to finding it?

    Thanks



    <script type="text/javascript">
            // Dynamic positioning override - not guaranteed to work in future versions!
            $telerik.$.popupDialog.prototype._positionForm = function () {
                // This will be called each time the form needs to be repositioned
                var $ = $telerik.$;
                $(this._targetElement).css({ top: "150px", left: "200px" });
            }
      
            function OnClientAppointmentContextMenu(sender, args) {
                sender.get_appointmentContextMenus()[0].set_enabled(false);
            }   
      
        </script>

    protected void RadScheduler1_TimeSlotCreated(object sender, Telerik.Web.UI.TimeSlotCreatedEventArgs e)
       {
           //if (!SecurityHandler.CanWrite(SafeValue.SafeInt(Session["UserID"].ToString()), "Scheduler Admin"))
               e.TimeSlot.CssClass = "Disabled";
       }
  2. Brian King
    Brian King avatar
    23 posts
    Member since:
    Jul 2009

    Posted 10 Jan 2011 Link to this post

    Hi Timothy, I was actually trying to do this a couple days ago. What I ended up doing was checking in the Appointment databind event to check and see if I wanted to disable the context menu for that appointment. If I did I set the context menu Id of the appointment.
    e.Appointment.ContextMenuID = "NoMenu";

    The on the aspx page I define NoMenu to be this:
    <telerik:RadSchedulerContextMenu runat="server" ID="NoMenu">
    </telerik:RadSchedulerContextMenu>

    Not the prettiest solution, but when I was looking through their documentation it had said that even on the client side the event wasn't able to be canceled, so this is the best workaround I could find.
Back to Top