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.
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.
I got silly problem. I use on image href statement for url redirection.
SO i got this menu tab
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />
<asp:MenuItem NavigateUrl="~/Test/TestODS.aspx" Text="Katalog" Value="Katalog"/>
<asp:MenuItem NavigateUrl="~/UploadNewOne.aspx" Text="Upload" Value="Upload"/>
and my image:
<a href='~/Default.aspx'>
<asp:Image ID="Image1" runat="server" Height="70px"
ImageUrl="~/Images/i-sova.jpg"/>
</a>
So problem is that when i click on Katalog , app redirect me on sub-domain Test/TestODS.aspx. From this page when i click on image im redirect on wrong url which doesnt exist >> /Test/Default.aspx
So anyone can help?
To use a tilde, you will need to add runat=server to the <a> tag
<a href='~/Default.aspx' runat="server">
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");
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.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.