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

disable radmenu dropdown button on master page

3 Answers 102 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Code
Top achievements
Rank 1
Code asked on 07 Aug 2013, 02:49 PM
Hi 

I'm using .net 2.0 and vb.net , web forms

On my master page there is a radmenu. This menu has 4 buttons that if you hover over any of them then , then a drop down will appear. and each drop down has 1 to 5 buttons.  example below

......home...... menu1........menu 2.......menu3.....menu4
                      a                 t                  s             v
                      b                                    w                    
                      c                                    q
                      d
                      e


my question is:

from the code behind on my .aspx page, how do I disable "menu1" and all its buttons.

I still want to see it  but just it must not link.

right now I have this   


Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

Me.FindControl("Mymenu").Visible = True

          'how do I disable "menu1" and all its buttons.

        Dim m As Telerik.Web.UI.RadMenu = CType(MyBase.Master.FindControl("Mymenu"), Telerik.Web.UI.RadMenu)

        m.item find("menu1").Disable()


    End Sub
End Class




3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Aug 2013, 03:58 AM
Hi,

Please try the following code snippet that I have tried to disable a RadMenuItem from Code behind.

VB:
Protected Sub Page_Load(sender As Object, e As EventArgs)
    Dim menu As Telerik.Web.UI.RadMenu = DirectCast(MyBase.Master.FindControl("RadMenu1"), Telerik.Web.UI.RadMenu)
    menu.FindItemByText("Menu1").Enabled = False
End Sub

Thanks,
Shinu.
0
Code
Top achievements
Rank 1
answered on 08 Aug 2013, 08:56 AM
Thanks for the reply but I get an error saying that 

Object reference not set to an instance of an object.

and it is not happy with this line  menu.FindItemByText("Menu1").Enabled = False

the name "Menu1" is correct


Thanks for your help

0
Code
Top achievements
Rank 1
answered on 08 Aug 2013, 09:44 AM
Hi I got your code to work - thanks -

I had to put the code in the "Page_LoadComplete" function

Thanks
Tags
Menu
Asked by
Code
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Code
Top achievements
Rank 1
Share this question
or