CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 3/25/2007 4:28:18 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 8 Views: 38 Favorited: 0 Favorite
9 Items, 1 Pages 1 |< << Go >> >|
supergriff
Asp.Net User
Preventing StaticBottomSeparatorImage appearing after LAST menuitem3/25/2007 4:28:18 PM

0

Hi

 Is there anyway of styling a menu control so there is a separator image / gap between each menuitem, but not after the last one?

I am using a StaticBottomSeparatorImage, which works great, except I cannot prevent it apeparing after the very last menu item..

 is there a way round this?

 thanks

sbyard
Asp.Net User
Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem3/25/2007 11:55:55 PM

0

Here is one way - althogh not the most elegantg - set an attribute on each last sibling in the sitemap file.  Pick this up in the bind event of the menu

 

Sitemap

<?xml version="1.0" encoding="utf-8" ?>

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

<siteMapNode url="Default.aspx" title="Default" description="">

<siteMapNode url="Page1.aspx" title="Page1" description="" />

<siteMapNode url="Page2.aspx" title="Page2" description="" IsLastSibling="true" />

</siteMapNode>

</siteMap>

 

 

Code

SiteMapNode nd = e.Item.DataItem as SiteMapNode;

if (nd != null)

if (nd["IsLastSibling"] != null)

e.Item.SeparatorImageUrl =

string.Empty;

else

e.Item.SeparatorImageUrl =

"~/Test.png";
If it was easy, everybody would be doing it.
supergriff
Asp.Net User
Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem3/26/2007 12:01:57 PM

0

Thanks - but how do i implement that within the menu? can i use a method in the code behind?  my code is below

 <asp:Menu ID="Menu2" runat="server" DataSourceID="SiteMapDataSource2" Orientation="Vertical" DynamicEnableDefaultPopOutImage="false" DynamicBottomSeparatorImageUrl="images/greymenudivider.gif" StaticPopOutImageUrl="images/greyarrow.gif" StaticEnableDefaultPopOutImage="true" Width="125px" DynamicMenuItemStyle-Width="125px" StaticbottomSeparatorImageUrl="images/greymenudivider.gif" CssClass="menu">
                        <StaticMenuStyle CssClass="StaticMenuStyle" />
                        <StaticMenuItemStyle CssClass="StaticMenuItemStyle" />
                        <StaticHoverStyle CssClass="StaticHoverStyle" />
                        <DynamicHoverStyle CssClass="DynamicHoverStyle" />
                        <DynamicMenuStyle CssClass="DynamicMenuStyle" />
                        <DynamicMenuItemStyle CssClass="DynamicMenuItemStyle" />
                        </asp:Menu>

sbyard
Asp.Net User
Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem3/26/2007 12:32:59 PM

0

Add a MenuItemDataBound Event for your menu, and add my code above into that.  You then set the image or class you want in code behind, rather than globally (to every item) the ASPX

You can add jsut about any attributes you want to the xml sitemap items, and pick these up as shown.  I use this quite a bit - e.g. to mark menu items that are for admin users only


If it was easy, everybody would be doing it.
supergriff
Asp.Net User
Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem3/27/2007 12:29:32 PM

0

brilliant, cheers... much appreciated.

 

supergriff
Asp.Net User
Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem3/31/2007 8:47:58 AM

0

Thanks for your help with this, I am interested though; what would you consider the most 'elegant' solution?

 

sbyard
Asp.Net User
Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem3/31/2007 9:45:28 AM

0

I would be looking for a solution that recognises the last item automatically, without having to manually edit a file.  If you change the menu around, you may have to edit the atributes - i.e. you add a new last item.

There was no obvious "current" clas to work with that gave the last sibling property (i.e. if null, then this is the last sibling).

It would be possible to perform a recursive earch on all the site map nodes and find each last sibling - then we can clear an image if set.

Unfortunately, dusing the menu databind process, the event we are using does not yet have the full sitemap node list, so the last sibling property is meaningless


If it was easy, everybody would be doing it.
supergriff
Asp.Net User
Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem3/31/2007 10:00:12 AM

0

I also have a related question; for the dynamic, pop out menu; is it possible to set a top and bottom image (only appearing before first item, and after last item) using gifs that contain transparent areas?

 i basically have a menu that has been designed with rounded corners, and when I have tried this, the transparent areas do not show as transparent.  (ive not been able to get them appearing at the top and bottom either though)

Guillote09
Asp.Net User
Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem4/16/2007 6:15:21 PM

0

This is my solution , you don`t have to add an atribute to the sitemap , just asking for the nextslibing == null is the same.

protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)

{

SiteMapNode nd = e.Item.DataItem as SiteMapNode;

if (nd != null)

{

if (nd.NextSibling == null)

e.Item.SeparatorImageUrl = string.Empty;

else

e.Item.SeparatorImageUrl =

"~/Images/menuItemSeparator.gif";

}

}

 Thanks for your help

9 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Preventing StaticBottomSeparatorImage appearing after LAST ... Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem ... Re: Preventing StaticBottomSeparatorImage appearing after LAST menuitem ...
portal installation problem w/ mssql - ng.asp-net-forum ... 1. after installing the portal starter kit without the SQL sever support .... preventing staticbottomseparatorimage appearing after last menuitem ...
Text / HTML Module Error - ng.asp-net-forum.dotnetnuke - error ... All of a sudden, after adding the text module to a Tab and clicking on Edit Text , .... preventing staticbottomseparatorimage appearing after last menuitem ...






setting dropdownlist value in wizard

value of the control at master page is not being set from the content page

adding accessibility controls to a web form

need to set enctype in form tag of the content page - using masterpages can't use multiple form tags

master page reuse

master with updatepanel + content with fileupload

error: content controls are allowed only in content page that references a master page.

content control not overriding contentplaceholder section in masterpage

treeview menu in the master page - how to keep menu state navigating to another page?

web based sitemap editor?

select and expand treeview

treeview control - font

why am i getting a gap underneath my navigation?

master pages, content pages title problem

gridview datakeynames in a master page

get the current page title from cahced page using a substitution control

linked horizontal and vertical menu controls

webresource.axd and authorization

events inside master.page

getting rid of the space above a master page

the page does not display the images in the runtime?

how to rearrange the page in browser

xml file structure

how to create treeview with hyperlink

how to place javascript datepicker in asp:content tag

how to access the navigateurl of child of treeview in masterpage to content page?

masterpage's postback event not firing for a single page...

problem in accessing child page controls

adding a custom style to the htmlheader

another treeview issue

   
  Privacy | Contact Us
All Times Are GMT