473,383 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Help: problems with ASP.NET menu on Web Part

Hi there,

I am having a weird problem in trying to use a ASP.NET menu inside a
custom web part. I am developing a custom web part that has a menu
inside (just the menu, nothing else). The menu is a
System.Web.UI.WebControls.Menu (ASP.NET 2.0) object. If I add the menu
to a simple ASPX web form, it works nice. However, I am adding it to
my web part, by overriding the RenderWebPart method and doing
something like:

theMenu.renderControl(writer) //writer is the HTMLTextWriter
parameter of the RenderWebPart method

There are two problems when the menu is displayed on the webpart
(after this webpart is deployed to a Sharepoint Site):
- When the page loads, the menu structure is always fully expanded
(menus, submenus, etc), even though I have set the StaticDisplayLevels
property to 1. It then collapses but only when I hover with the mouse
pointer over each top level Menu Item.
- Whenever I pass with the mouse over each menu item, if it has
dynamic submenus, they get displayed but in the wrong place. What's
more, I see a "phantom DIV", more or less with the same size as the
submenu that should be displayed, but that DIV and the menu items
appear in different places on the page !!

I have not messed up with the menu's CSS style sheets, nor set any
other property other than the Orientation property to Horizontal (in
vertical it's weird as well). I suspect it has something to do with
the page structure that Sharepoint renders to the browser. Since that
structure is full of DIV tags, and the menu also has some DIV tags
when it renders to the client, I suspect that the browser is getting
"lost" in where to position the DIVs of each submenu and ends up
placing them in the wrong places. As I said, outside the sharepoint
and webpart environment (in a plain simple asp.net page it works
fine).

Has anyone had any similar problems ? I am getting totally lost here
and really could use some help...

Thanks,

Joao Maia
Jun 27 '08 #1
3 2190
I can tell you why it's happening, I'm not sure about the solution though.

The Menu control is a DHTML control, besides rendering the HTML it might
register scripts on other parts of the page (probably it just spit out the
DIV tags and registers some script to generate the menu programatically), so
you cannot render like that.

Maybe if you add the Menu to you WebPart controls collection before
rendering it, it will be able to get references to the rest of the page and
will render correctly. I don't have the time to try it though.

Also if you make your webpart composite (by adding controls programmatically
to it and letting it render them rather than rendering the HTML manually) it
would definitely work.

Hope that helps,
Fernando L Rodriguez, MCP

"Joćo Maia" <jm***@yahoo.comwrote in message
news:72**********************************@l42g2000 hsc.googlegroups.com...
Hi there,

I am having a weird problem in trying to use a ASP.NET menu inside a
custom web part. I am developing a custom web part that has a menu
inside (just the menu, nothing else). The menu is a
System.Web.UI.WebControls.Menu (ASP.NET 2.0) object. If I add the menu
to a simple ASPX web form, it works nice. However, I am adding it to
my web part, by overriding the RenderWebPart method and doing
something like:

theMenu.renderControl(writer) //writer is the HTMLTextWriter
parameter of the RenderWebPart method

There are two problems when the menu is displayed on the webpart
(after this webpart is deployed to a Sharepoint Site):
- When the page loads, the menu structure is always fully expanded
(menus, submenus, etc), even though I have set the StaticDisplayLevels
property to 1. It then collapses but only when I hover with the mouse
pointer over each top level Menu Item.
- Whenever I pass with the mouse over each menu item, if it has
dynamic submenus, they get displayed but in the wrong place. What's
more, I see a "phantom DIV", more or less with the same size as the
submenu that should be displayed, but that DIV and the menu items
appear in different places on the page !!

I have not messed up with the menu's CSS style sheets, nor set any
other property other than the Orientation property to Horizontal (in
vertical it's weird as well). I suspect it has something to do with
the page structure that Sharepoint renders to the browser. Since that
structure is full of DIV tags, and the menu also has some DIV tags
when it renders to the client, I suspect that the browser is getting
"lost" in where to position the DIVs of each submenu and ends up
placing them in the wrong places. As I said, outside the sharepoint
and webpart environment (in a plain simple asp.net page it works
fine).

Has anyone had any similar problems ? I am getting totally lost here
and really could use some help...

Thanks,

Joao Maia

Jun 27 '08 #2
You do not add the controls to webpart by overriding the RenderWebPart
method.

Add it in CreateChildControls() method using Controls.Add() method.

--
Madhur

"Joćo Maia" <jm***@yahoo.comwrote in message
news:72**********************************@l42g2000 hsc.googlegroups.com...
Hi there,

I am having a weird problem in trying to use a ASP.NET menu inside a
custom web part. I am developing a custom web part that has a menu
inside (just the menu, nothing else). The menu is a
System.Web.UI.WebControls.Menu (ASP.NET 2.0) object. If I add the menu
to a simple ASPX web form, it works nice. However, I am adding it to
my web part, by overriding the RenderWebPart method and doing
something like:

theMenu.renderControl(writer) //writer is the HTMLTextWriter
parameter of the RenderWebPart method

There are two problems when the menu is displayed on the webpart
(after this webpart is deployed to a Sharepoint Site):
- When the page loads, the menu structure is always fully expanded
(menus, submenus, etc), even though I have set the StaticDisplayLevels
property to 1. It then collapses but only when I hover with the mouse
pointer over each top level Menu Item.
- Whenever I pass with the mouse over each menu item, if it has
dynamic submenus, they get displayed but in the wrong place. What's
more, I see a "phantom DIV", more or less with the same size as the
submenu that should be displayed, but that DIV and the menu items
appear in different places on the page !!

I have not messed up with the menu's CSS style sheets, nor set any
other property other than the Orientation property to Horizontal (in
vertical it's weird as well). I suspect it has something to do with
the page structure that Sharepoint renders to the browser. Since that
structure is full of DIV tags, and the menu also has some DIV tags
when it renders to the client, I suspect that the browser is getting
"lost" in where to position the DIVs of each submenu and ends up
placing them in the wrong places. As I said, outside the sharepoint
and webpart environment (in a plain simple asp.net page it works
fine).

Has anyone had any similar problems ? I am getting totally lost here
and really could use some help...

Thanks,

Joao Maia
Jun 27 '08 #3
Hi,

Thanks, that worked ok. But now I have another problem. I want to use
the sharepoint css menu styles and themes on my web part's menu (to
give it a coherent look and feel to the rest of the sharepoint site
and to change the menu colors when the user changes the sharepoint
theme) and I can't seem to get around to do it. Anyone knows how to do
this ?

thanks,

Joao Maia

On 2 maio, 06:46, "Madhur" <s...@df.comwrote:
You do not add the controls to webpart by overriding the RenderWebPart
method.

Add it in CreateChildControls() method using Controls.Add() method.

--
Madhur

"Joćo Maia" <jm...@yahoo.comwrote in message

news:72**********************************@l42g2000 hsc.googlegroups.com...
Hi there,
I am having a weird problem in trying to use a ASP.NETmenuinside a
custom web part. I am developing a custom web part that has amenu
inside (just themenu, nothing else). Themenuis a
System.Web.UI.WebControls.Menu(ASP.NET 2.0) object. If I add themenu
to a simple ASPX web form, it works nice. However, I am adding it to
my web part, by overriding the RenderWebPart method and doing
something like:
theMenu.renderControl(writer) *//writer is the HTMLTextWriter
parameter of the RenderWebPart method
There are two problems when themenuis displayed on the webpart
(after this webpart is deployed to a Sharepoint Site):
- When the page loads, themenustructure is always fully expanded
(menus, submenus, etc), even though I have set the StaticDisplayLevels
property to 1. It then collapses but only when I hover with the mouse
pointer over each top levelMenuItem.
- Whenever I pass with the mouse over eachmenuitem, if it has
dynamic submenus, they get displayed but in the wrong place. What's
more, I see a "phantom DIV", more or less with the same size as the
submenu that should be displayed, but that DIV and themenuitems
appear in different places on the page !!
I have not messed up with themenu'sCSS style sheets, nor set any
other property other than the Orientation property to Horizontal (in
vertical it's weird as well). I suspect it has something to do with
the page structure that Sharepoint renders to the browser. Since that
structure is full of DIV tags, and themenualso has some DIV tags
when it renders to the client, I suspect that the browser is getting
"lost" in where to position the DIVs of each submenu and ends up
placing them in the wrong places. As I said, outside the sharepoint
and webpart environment (in a plain simple asp.net page it works
fine).
Has anyone had any similar problems ? I am getting totally lost here
and really could use some help...
Thanks,
Joao Maia- Ocultar texto entre aspas -

- Mostrar texto entre aspas -
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: google | last post by:
I've been reading old posts and Googling all nite for solutions to my problems, but I can't find any. I appreciate any help you can provide. Here is the link to the problem web site: ...
7
by: mike | last post by:
Hello, I am kind of new to this javascript stuff and I am constantly having problems trying to get my webpage validated. I have the following <script>printdate();</script> and when I validate it...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
9
by: Nicole | last post by:
Okay, so I was working primarily in dreamweaver and the site looks very good in both IE (our customers primarily use this) and Firefox (my new 'thing'), but I ran it through the validator and...
2
by: Peter Proost | last post by:
Hi, I've got the following ownerdraw menu: drag a mainmenu on a form and add some menuitems to it, set all the menuitems to ownerdraw = true and for every menuitem add this code (replace...
24
by: Rhino | last post by:
I am dabbling with print CSS for the first time and I need some guidance. The web pages on my site look fine - to my untrained eye - when displayed on the monitor in any of the standard browsers....
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
1
by: ckking | last post by:
ok the part that i had earlier was supposed to part of this cipher, im having trouble with it not converting spaces char ch; char inputfile; cout << "enter input filename:"<<endl;...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.