0

I am using asp menu.I want to disable it and enable it using javascript. Please help

  <asp:Menu ID="MainMenu" runat="server" Orientation="Horizontal" DataSourceID="HAPSMainMenu" 
                MaximumDynamicDisplayLevels="3" DynamicEnableDefaultPopOutImage="true" StaticEnableDefaultPopOutImage="false"
                CssClass="mainMenu" DynamicVerticalOffset="1" DynamicHorizontalOffset="0" 
                OnMenuItemDataBound ="mainMenu_DataBound" Height="18pt" Width="100%"
                 >

                <StaticMenuItemStyle CssClass="menuItem" Width="125" />
                <DynamicMenuStyle CssClass="subMenu" />
                <DynamicMenuItemStyle CssClass="subMenuItem" Width="120pt"  />
                <DynamicHoverStyle CssClass="subMenuItemHover" />
                <DynamicSelectedStyle CssClass="dynamicselectedStyle" />
                <StaticHoverStyle CssClass="menuHover" ForeColor="midnightblue"/>
                </asp:Menu>

I want to disable the whole menu bar with Javascript and I have the menu Id by using firefox...I was hoping for a statement that would disable the whole menu.

1
  • Please post what you have tried? Some code chunks, perhaps? Commented Mar 22, 2011 at 16:31

2 Answers 2

1

Do you have jQuery? Do you want to make the menu disappear?

Maybe something like $(".mainMenu").hide()?

Sign up to request clarification or add additional context in comments.

4 Comments

No I dont use Jquery...I dont want to hide the menu...I want the user to be unable to use the menu....buitthe menu should be displayed.
I want something like document..(menuid).disabled=true;
Then you should set the selectable property to False. Edit: You might want to test if IsPostBack first.
Can you please give me an example code for using selectable cz I dont see that option in Javascript in the intellisense.
0

Have you tried placing the asp:Menu in a div and then disabling the div?

<div id="myDiv">
...<asp:Menu ...
</div>

Then somewhere on your client code, do this:

var myDiv = document.getElementById('myDiv');

myDiv.disabled = true;

2 Comments

I just tried it .Yes it does work...but the links are garyed out but if I clik on it the links are working...I want to disable it just like it owuld be disabeled if I open a popup
You'll need to look at the rendered HTML. I think the asp:Menu control renders out <ul><li>link1.html</li></ul> type markup. You could try getElementByTagName("li") and then loop the results and check the .classname property and if it's menuItem then set onclick = null;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.