asp:Menu control does not work well in all browsers

A

AAaron123

I IE a menu item looks like:
Events Calendar

If I click it I get a dropdown list of other menu items.
Just like in Windows.

But in some browsers the menuitem looks like:
Events Calendar Expand Events Calendar

If I click it I get:

Events Calendar Events Locations ^Up One Level

Pretty ugly, I think.

Anything I can do about that?

I'm using the asp:Menu control.


Thanks
 
G

Gregory A. Beamer

I IE a menu item looks like:
Events Calendar

If I click it I get a dropdown list of other menu items.
Just like in Windows.

But in some browsers the menuitem looks like:
Events Calendar Expand Events Calendar

If I click it I get:

Events Calendar Events Locations ^Up One Level

Pretty ugly, I think.

Anything I can do about that?

I'm using the asp:Menu control.


I would personally consider using the CSS Friendly adapters and writing CSS
to configure the menu rather than have the menu control output the ugly
tables.

This means you are "on your own", but there are plenty of menu scripts out
there you can use and it is fairly easy to find CSS that will work for you.
 
A

AAaron123

Before I make the suggested changes I'd like to clear up something else that
just occurred. Unless you think those changes will fix this too.

After some debugging the following is true.

In Sub Page_PreRender I do:

Response.Write("<script type='text/javascript'>")
Response.Write("</script>")


The source in the browsers looks like:

<script type='text/javascript'>var htmlStyle =
document.getElementsByTagName('html')[0].style;htmlStyle.scrollbarBaseColor
= 'black';</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
...

When I removed that code from Page_PreRender my asp:Menu's drop-downs became
white rectangles instead of a list of menu items.

So I guessed that maybe if the DOCTYPE is not the first line it is ignored
and removing the script line made it effective.

Does that sound correct??


So I removed the DOCTYPE line from my code and the drop-down menu list looks
OK (with or without the script line)

I guess the browser defaults to something different if there is no DOCTYPE.

What is the that default?


I'd be surprised if you ran across this before but do you have any idea what
might be happening?


Thanks
 
A

AAaron123

Since I posted I've changed to
Page.ClientScript.IsClientScriptBlockRegistered

but this problem is with the DOCTYPE ot asp:Menu

The script line simply masked that problem.



Thanks
 
A

AAaron123

Mark Rae said:
In addition to Gregory's (correct, IMO) suggestion that you use the CSS
Friendly Adaptors version of the menu control (Google it...), you can use
the technique described here:
http://www.velocityreviews.com/forums/t386549-mac-and-aspnet-20.html to
make the asp:Menu webcontrol display properly in Safari / Chrome etc, and
you can use the technique described here:


I created a PageEx class inheriting from System.Web.UI.Page and inserted
Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreInit

If (Request.Browser.Browser.Contains("Safari")) Then

Me.ClientTarget = "uplevel"

End If

End Sub



And that fixed Safari. Is that need because asp.net has the wrong capability
for Safari?



Also, I searched the internet and only found references to Safari.

Do you know what to check for as far as other browsers that need "uplevel"?

I mean is FireFox and Chrome the strings that I should use in my "if"
ststement?

Are there others?

I expected to find such a list but did not.



Thank a lot. This was an easy fix.

Now I'll read more about Friendly Adaptors.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top