I have an asp.net menu with a few menuitems. 1 of the items has submenuitems.
Problem is that after clicking around on my site for a while, the menu's formatting will suddenly get messed up (the background image will only show in a tight rectangle around the text, and the text will be lower than the separator images) and the text of the menuitem with submenuitems has the phrase Expand MenuItem_Text added to it ("Setup" -> "Setup Expand Setup"), but it's not actually expandable.
I've discovered that logging out and then logging back in solves this, as does clearing the cache, however, I can't expect my users to know that.
I already have the AppleWebKit line in my code, so it's not that.
Edit:
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" BackColor="transparent"
StaticMenuItemStyle-ItemSpacing="0" StaticEnableDefaultPopOutImage="False" DynamicEnableDefaultPopOutImage="false">
<Items>
<asp:MenuItem NavigateUrl="~/Main.aspx" Text="Home" SeparatorImageUrl="~/Images/menubarmid.png" />
<asp:MenuItem Text="Setup" SeparatorImageUrl="~/Images/menubarmid.png" Selectable="false">
<asp:MenuItem NavigateUrl="~/ASetup.aspx" Text="A" />
<asp:MenuItem NavigateUrl="~/BSetup.aspx" Text="B" />
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/Logout.aspx" Text=" Logout "></asp:MenuItem>
</Items>
<StaticHoverStyle CssClass="static_hover_style" />
<DynamicHoverStyle CssClass="dynamic_hover_Style" />
<StaticMenuStyle CssClass="static_menu_style" />
<DynamicMenuStyle CssClass="dynamic_menu_style" />
<StaticMenuItemStyle CssClass="static_menuitem_style" />
<DynamicMenuItemStyle VerticalPadding="3px" HorizontalPadding="10px" CssClass="dynamic_menuitem_style" />
</asp:Menu>
I came up with the same sort of issue and I found that setting the StaticPopOutImageTextFormatString property to an empty string made the equivalent of " expand Setup" to disappear .
It looks like Chrome was trying to display the alternate text for the pop-out image instead of simply not displaying an image to indicate that the link could pop out.
As such my asp code looked something like this:
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False" StaticPopOutImageTextFormatString="">
</asp:Menu>
This, in addition to the AppleWebKit code seems to allow my code to work. I did have to do a shift F5 in order to reset the cache every time I restart the test server.
I had this happen to an asp.net site of mine when it was deployed to a server. I eventually found that in IIS the target framework for the site was 2.0. I changed it to 4.0 and hey presto the sitemap menu worked as expected.
Related
I've been working through an issue where I want to update some control states prior to downloading a file. Using info from other StackOverflow users, I've arrived at a solution that works 'mostly'. I'm updating my controls in the main button click handler then using a RegisterStartupScript to execute a click on a hidden button to perform the actual download.
All that works as-expected.
The issue I'm coming across is that the placement of the startup script seems to be interfering with the normal rendering of my menu at the top of my page.
Normal Menu
Corrupted Menu
I have a menu setup in the site masterpage using an asp:Menu control and LoginView, and this ends up adding a new Sys.WebForms.Menu script at the bottom of the page through whatever magical mystical potion Microsoft uses for this control.
The last few lines of my html source ends up looking like this when the RegisterStartupScript is run:
<script type='text/javascript'>document.getElementById('btnHiddenDownloadAction').click();</script><script type='text/javascript'>new Sys.WebForms.Menu({ element: 'MenuLoginView_NavigationMenu', disappearAfter: 500, orientation: 'horizontal', tabIndex: 0, disabled: false });</script></form>
</body>
</html>
The first script with the btnHiddenDownloadAction click is what I'm adding via the RegisterStartupScript() call. The second script is getting placed there by the ASP.NET menu control.
The menu control on my masterpage is defined like this (truncated)
<asp:LoginView ID="MenuLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
</AnonymousTemplate>
<RoleGroups>
<asp:RoleGroup Roles="Administrator">
<ContentTemplate>
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
IncludeStyleBlock="false" Orientation="Horizontal" OnPreRender="NavigationMenu_PreRender">
<StaticSelectedStyle Font-Bold="true" />
<Items>
<asp:MenuItem NavigateUrl="~/KeyGeneration.aspx" Text="Feature Activation" />
<asp:MenuItem NavigateUrl="~/GenerateAALicense.aspx" Text="Generate AA License" />
<asp:MenuItem NavigateUrl="~/DevicePasswordGeneration.aspx" Text="Device Password Generator" />
<asp:MenuItem Text="Reporting">
<asp:MenuItem NavigateUrl="~/KeyHistoryReport.aspx" Text="Feature Activation History Report"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/AALicenseReport.aspx" Text="AA License Report"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/DevicePasswordHistoryReport.aspx" Text="Device Password History Report"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/ManageUsers.aspx" Text="Manage Users" />
<asp:MenuItem NavigateUrl="~/ManageFeatures.aspx" Text="Manage Features" />
<asp:MenuItem NavigateUrl="~/ChangePassword.aspx" Text="Change Password" />
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About" />
</Items>
</asp:Menu>
</ContentTemplate>
</asp:RoleGroup>
I've tried inserting this as a client script rather than a startup script, but the button control doesn't exist at that point, so the button click doesn't execute. I've tried reformatting the script to add a 'div' tag, and I've tried simplifying the call to call a script defined elsewhere, both of those still have that menu problem.
My ASP.Net Menu & associated MenuItems are not rendering correctly in Chrome. That is to say, they are all rendering simultaneously, in sequential order down the page, rather than as drop-down menus.
They work normally when I run the page from the solution (including in Chrome), but when I deploy it to the test server, the nested nature of the menus are lost. In my example, "Admin Maintenance," "Grid Maintenance," "Today Screen" and "Setup should all be items under the "Admin" menu, and the last 3 should be items under "Setup." They are setup correctly and, as mentioned before, they work fine when run from within VS.
A screenshot:
My code:
<asp:Menu ID="Menu1" runat="server" CssClass="menu"
EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal" StaticDisplayLevels="1">
<Items>
<asp:MenuItem Text="PTS Home" Value="PTS Main" NavigateUrl="Default.aspx">
</asp:MenuItem>
<asp:MenuItem Text="Admin" Value="Admin">
<asp:MenuItem Text="Admin Maintenance" Value="Admin_Admin Maintenance" NavigateUrl="~/Secure/Admin/AdminMaintenance.aspx">
</asp:MenuItem>
<asp:MenuItem Text="Grid Maintenance" Value="Admin_Grid Maintenance" NavigateUrl="~/Secure/Admin/GridMaintenance.aspx">
</asp:MenuItem>
<asp:MenuItem Text="Today Screen" Value="Admin_Today Screen" NavigateUrl="~/Secure/Admin/TodayScreen.aspx">
</asp:MenuItem>
<asp:MenuItem Text="Setup" Value="Admin_Setup">
<asp:MenuItem Text="Reserve Owner Codes" Value="Admin_Setup_Reserve Owner Codes"
NavigateUrl="~/Secure/Admin/MaintainOwnerCodes.aspx"></asp:MenuItem>
<asp:MenuItem Text="Reserve Product Codes" Value="Admin_Setup_Reserve Product Codes"
NavigateUrl="~/Secure/Admin/MaintainProductCodes.aspx"></asp:MenuItem>
<asp:MenuItem Text="Enter New Grade" Value="Admin_Setup_Enter New Grade" NavigateUrl="~/Secure/Admin/MaintainGrades.aspx">
</asp:MenuItem>
</asp:MenuItem>
</asp:MenuItem>
... //Other items
</Items>
</Menu>
The weirdest/most annoying thing is that on the production server, when I first load the page, it does this, but I leave & come back, it fixes itself. On the test server, it just stays broken.
Also, this behavior occurs in IE 8, as well, though I suspect that that's a red herring, and none of my users use IE 8, anyway.
I've included the IIS keyword, as I have a feeling that this is more a server issue than a code issue, but I'm not certain. I'm not certain which version of Windows Server/IIS we run, & our server admin is out at the moment. I'll update the question later when I have that info, but I was hoping that there might be an answer anyway.
UPDATE
Windows Server 2008 R2 SP1, IIS7.
Figured out what was going on. Came upon it somewhat by accident.
The page uses mixed content (the menu itself being unsecure content). Chrome automatically blocks unsecure content on mixed pages, displaying a shield in the address bar. Click the shield, tell it to load unsecure content, and bam - no more weird behavior.
http://knowledgebase.pearsonschool.com/kmp/article/AA-05523/0/GPOINT%3A-How-do-I-display-mixed-content-with-Google-Chrome.html
Of course, I should probably just fix the menu to be secure, but this at least tells me what was going on, and may help others with similar problems.
I have an asp:menu and I have for eg 3 menuItem: First Second Third and the second item have 2 submenuItems i want to show the 2 submenuitems only when I click on the Second menuitem not when I hover the mouse over. I'll put the code of menu here
<asp:Menu ID="Menu_WebSite" runat="server"
DynamicHorizontalOffset="10" TabIndex="1"
Font-Names="Verdana" Font-Size="12px"
StaticSubMenuIndent="10px" Orientation="Horizontal"
StaticEnableDefaultPopOutImage="false" BackColor="#f0f0f0">
<StaticSelectedStyle ForeColor="Black" />
<DynamicHoverStyle BackColor="#f0f0f0" ForeColor="Black" />
<DynamicMenuItemStyle BackColor="#f0f0f0" HorizontalPadding="25px" VerticalPadding="3px" />
<DynamicMenuStyle BackColor="#f0f0f0" ForeColor="Black" />
<DynamicSelectedStyle BackColor="#f0f0f0" Forecolor="Black" />
<StaticHoverStyle BackColor="#f0f0f0" ForeColor="Black" />
<StaticMenuItemStyle BackColor="#f0f0f0" HorizontalPadding="10px" VerticalPadding="3px" />
<StaticItemTemplate>
<%#Eval("text")%>
</StaticItemTemplate>
</asp:Menu>
my answer is purely theoretical, so you may wish to hold out for someone willing to do leg work for you.
The hover styles can be controlled with CSS. It may be possible to write CSS to ensure the submenu items are hidden even when the user hovers over the main menu items, then change the CSS class dynamically with JavaScript when the user clicks the menu item.
Bearing in mind that clicking the menu item may cause a postback, you may need to show/hide the submenus in server code...
Also, you'll need to consider that you may need to hide the sub menus manually using the onClick event again.
Finally, you may wish to consider not using the ASP Menu for this, because it's designed to be used as a hover menu. You might be better off writing your own implementation, depending on whether you really need the ASP Menu functionality. There are many examples of good menus online, so you might find one that does what you're looking for with more ease. The ASP.NET TreeView control may provide you with a much closer starting point.
A quick Google throws up the following blog that may be what you're looking for:
http://msd-bml.blogspot.com/2008/09/aspnet-menu-click-instead-of-hover.html
Evening all,
I am struggling with a couple of problems that I could do with your help with. I apologise if these have been covered in other pages, if they have could you point me in the direction of those pages. The problems are as follows:
I've got a simple website that contains a master page with a menu on it. The menu works fine with IE and Firefox but when I try it in Chrome clicking the menu doesn't seem to work.
Here is how I have set the menu up:
How do I get the click on the menu to display the correct page?
<asp:Menu ID="Menu1" runat="server" Height="16px" Orientation="Horizontal"
style="margin-top: 0px" Width="917px">
<Items>
<asp:MenuItem ImageUrl="~/Images/MenuHome.jpg" NavigateUrl="~/Default.aspx"
></asp:MenuItem>
<asp:MenuItem ImageUrl="~/Images/MenuMenu.jpg" NavigateUrl="~/Menu.aspx"
></asp:MenuItem>
<asp:MenuItem ImageUrl="~/Images/MenuPriceList.jpg" NavigateUrl="~/PriceList.aspx"
></asp:MenuItem>
<asp:MenuItem ImageUrl="~/Images/MenuOrdering2.jpg"
NavigateUrl="~/Ordering.aspx" >
</asp:MenuItem>
<asp:MenuItem ImageUrl="~/Images/MenuOccasions.jpg"
NavigateUrl="~/Occasions.aspx">
</asp:MenuItem>
<asp:MenuItem ImageUrl="~/Images/MenuWeddings2.jpg" NavigateUrl="~/Weddings.aspx"
></asp:MenuItem>
<asp:MenuItem ImageUrl="~/Images/MenuEvents.jpg" NavigateUrl="~/Events.aspx"
></asp:MenuItem>
<asp:MenuItem ImageUrl="~/Images/MenuGallery.jpg" NavigateUrl="~/Gallery.aspx"
></asp:MenuItem>
<asp:MenuItem ImageUrl="~/Images/MenuContactUs.jpg"
NavigateUrl="~/ContactUs.aspx" >
</asp:MenuItem>
<asp:MenuItem ImageUrl="~/Images/MenuBlog.jpg"
NavigateUrl="~/dasblog/default.aspx" >
</asp:MenuItem>
</Items>
</asp:Menu>
The menu is wrapping round on to two rows, how do I keep it on a single row?
Thanks for the help.
After some more digging I have found the solution.
The answer can be found here: http://forums.asp.net/p/1369765/2860698.aspx#2860698
I've copied the bits you will need and pasted it in here:
You need to add an App_Browsers folder to the project and add a new item Add New Item...
Select "Browser File" and name it Chrome.browsers.
Comment out the default stuff and insert this from the link above:
<browsers>
<browser refID="safari1plus">
<controlAdapters>
<adapter controlType="System.Web.UI.WebControls.Menu" adapterType="" />
</controlAdapters>
</browser>
</browsers>
This will make the menu work, and it also stops it from wrapping around.
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.