ASP:MENU On click open submenu - asp.net

I have the following ASP:Menu
<asp:Menu id="menu_mymenu" runat="server" OnMenuItemClick="menu_mymenu_Click">
<Items>
<asp:MenuItem Text="menu_1" Value ="menu_1">
<asp:MenuItem Text="menu_a" Value="menu_a" />
<asp:MenuItem Text="menu_b" Value="menu_b"/>
</asp:MenuItem>
</Items>
</asp:Menu>
On mouse over it displays submenus menu_a and menu_b. I would like the onclick on menu_1 to display the submenus menu_a and menu_b in the same way without posting back. Is there anyway to do this?

It looks like this is not something that is particularly easy to do and may be a bit hacky. I've seen a lot of suggestions of trying to use a treeview instead of the menu control. Anyway here are some resources I found and a solution that appears may do the trick:
http://forums.asp.net/t/1250342.aspx
Is it possible to force a menu popout to trigger on click instead of mouseover?
If it is absolutely necessary to have this be on click then it would be worth looking into a solution that fits your needs. In this case I would recommend looking into a treeview or looking at a purely css / javascript solution.
Hopefully this gets you down the right path!

I have customized as per the requirement; below is the link for complete solution.
https://stackoverflow.com/a/60986351/3099784

Related

ASP.NET website, Buttons are just hyperlinks

hoping someone can help me I think I know what the issue is but I can't seem to make it work.
I have a small website written with VB web developer 2010.
I am looking to move the host company I am using but the problem I am running into is that the buttons at the top of the page:
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
</Items>
</asp:Menu>
The old host they show up fine. New host (VPS server that I do everything myself) show up as only a hyperlink.
I think that it is the version of ASP.net I compile it with, currently 3.5, but I could be wrong, I have tried multiple times to get it to work.
Any help is appreciated. Thanks!
Are you sure you copied over the CSS files that go along with the project, and that they are in a directory that has the correct permissions?
Read this link then: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.renderingmode.aspx
In particular it references a rendermode setting that you may need to set when you are changing from 3.5 or lower to 4.0
The value of the RenderingMode property determines how the menu
control renders markup for the Menu control. In ASP.NET 3.5 and
earlier versions, the Menu control uses HTML table elements and inline
styles to specify the appearance of the menu in a browser. In ASP.NET
4 and later versions, by default the Menu control uses HTML listitem
elements and cascading style sheet (CSS) styles. If you do not set
this property, the Menu control renders markup that is appropriate to
the ASP.NET version that is indicated by the
Control.RenderingCompatibility property. The Menu control uses the
following rules:
If the value of the RenderingCompatibility property is 3.5, the Menu control uses HTML table elements and inline styles.
If the value of the RenderingCompatibility property is 4.0 or greater, the Menu control uses HTML listitem elements and CSS styles.
This property is provided for backward compatibility. If the
RenderingCompatibility property indicates that you want controls to
generate HTML that is compatible with ASP.NET 4 or later, but you want
the Menu control to be an exception that uses earlier behavior, you
can set this property to Table. For example, if you have a Web page
that displays text from right to left you might want to set this
property to Table because some browsers do not display the List mode
markup properly for right-to-left text.
Solution!
Server side: change the asp.net version to 4.0 using the answer located here
In your Web.config
I had a line with this
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
Change to
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID"/>
Complete!
Thank you for your help E.J. without knowing it was CSS related I could not have come across the answer.

Retrieve MenuItem with "special" text in Asp.Net

I have a WebControls.Menu which holds several MenuItem.
I can use FindItem to retrieve most of them.
But it doesn't work for the two items which text is more than just a word.
Those two items' text being:
Save as...
Add new member
I tried setting the separator to | (pipe character) just to be sure it wasn't just that but it didn't fix my problem.
Is there something wrong when using a space or a dot?
Since FindItem of the Menu-Control uses the Value of an MenuItem to find it and not the Text, set and use that Property to find specific controls.
This also makes the FindItem-Function language-indipendent.
ASPX
<asp:Menu ID="Menu1" runat="server" StaticDisplayLevels="3">
<Items>
<asp:MenuItem Text="Datei" Value="File">
<asp:MenuItem Text="Neu" Value="New"></asp:MenuItem>
<asp:MenuItem Text="Öffnen" Value="Open"></asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
C#
Menu1.FindItem("File");

trying to disable the telerik editor control in asp

I was thinking to do this server side, but what i was wanting to do was disable the telerik control called the "Editor." Located at the site: telerick editor control.
My reasoning behind this was that I wanted to give a user the exact look and feel of the object while having everything disabled. I didnt want to use an image at all because it would be stretched, shrank, clicked, etc and wanted to maintain how the editor would look. I had an alternate option i COULD do but not only it would be ineffecient, but have holes to open up for injection.
Looking through the API for that i didnt see which way to accomplish that.
I was thinking to do jquery maybe on the client side to disable, but why do that when you can set the item itself be flagged as disabled and never be entirely sent to the client.
Thoughts? Ideas? How would you go about it? I didnt see methods or attributes that really led to what i was doing.
You can just set enabled="false" on the radEditor declaration in your aspx page:
http://www.telerik.com/help/aspnet-ajax/editor-disabling-radeditor.html
<telerik:RadEditor runat="server" ID="RadEditor1" Enabled="false">
<Content>
<strong>sample content</strong>
</Content>
</telerik:RadEditor>
On the Server Side you can do
RadEditor1.Enabled = false;
In jquery,
try
$("#RadEditor1").prop('disabled', true);

Turn off link on menu items without URLs

I am building a menu for my asp.net application using the Menu control which is in turn being fed by a table via a Hierarchical data object. It works great, except that I cannot figure out how to configure the Menu control to disallow clicking on the menu items with no designated URLs.
For instance, I have a static toplevel menu item. I hover my mouse over it and a dynamic menu list appears for my choosing pleasure. Each dynamic menu item contains a link to a page that is invoked when I click my mouse on it. Whereas the static top level menu goes nowhere. How can I make it so that clicking on that top level static menu does not act like it is a link?
Thanks
jw
Is this perhaps what you are looking for?:
<Items>
<asp:MenuItem Selectable="false" Text="Search Engines" >
<asp:MenuItem NavigateUrl="http://www.google.com" Text="Google"></asp:MenuItem>
<asp:MenuItem NavigateUrl="http://www.google.com" Text="Google"></asp:MenuItem>
<asp:MenuItem NavigateUrl="http://www.google.com" Text="Google"></asp:MenuItem>
</asp:MenuItem>
</Items>
Good luck!

onmenuitemclick Event is Not Firing in IE6 ASP.NET

I had a asp.net Menu control on the master page and binded in the runtime based on the user access rights to the module. The problem I face is the MenuItemClick event is not fired when I view the website in the Internet Explorer(6.0). But the same is working fine in Firfox. I tried googling but none of the solutions worked for me. I was wondring if some one could help me to fix this.
There is no problem with Internet Explorer.
When you used MenuItem you probably used this form:
<asp:Menu ID="NavigationMenu" OnMenuItemClick="NavigationMenu_MenuItemClick" runat="server">
<items>
<asp:MenuItem Text="menuItem1" NavigateUrl="Web.aspx" />
<asp:MenuItem Text="menuItem2" NavigateUrl="otherWeb.aspx" />
</items>
</asp:Menu>
When you wrote in this form, the browser dosen't respect your event, because you gave it the URL to navigate to.
If you want that the browser will respect your event and handle it as well, you should delete the "NavigateUrl" attribute and it will work out.

Resources