I have a menu from a sitemap file that im showing on a master page, its working fine, the only problem i have is that not all my imagelink have the same width.
If i changes the style.Width = Unit.Pixel to 100% then all the link have the same width as the first link
So u can see that if the image is smaller then the first one, then it will repeat it self and if its to big then the first one then some of the image is missing.
If i changes the width to maybe 250, then its easy to see that the images is repeating it self.
How can i get the style.Width = Unit.Pixel to use the right width of the image(s) !?
can i some place write the 6 images width !?
My code is
Protected Sub navcontainer_MenuItemDataBound(sender As Object, e As System.Web.UI.WebControls.MenuEventArgs) Handles navcontainer.MenuItemDataBound
Dim map = CType(e.Item.DataItem, SiteMapNode) 'get SiteMapNode
Dim css = map("css") 'cache cssclass, used several places in this method
classes(e.Item) = css 'place css in lookup variable for use in DynamicItemTemplate
Dim style As BGImageStyle
Dim selector = String.Format(".{0}", css)
If e.Item.Selected Then
style = New BGImageStyle(map("imgActive")) 'use active image for selected page
style.Width = Unit.Pixel(250)
style.Height = Unit.Pixel(46)
Page.Header.StyleSheet.CreateStyleRule(style, Nothing, selector)
Else
style = New BGImageStyle(map("imgLink")) 'use default image for not selected page
selector = String.Format(".{0}", css)
style.Width = Unit.Pixel(250)
style.Height = Unit.Pixel(46)
Page.Header.StyleSheet.CreateStyleRule(style, Nothing, selector)
End If
style = New BGImageStyle(map("imgHover"))
selector = String.Format(".{0}:hover", css)
style.Width = Unit.Pixel(250)
style.Height = Unit.Pixel(46)
Page.Header.StyleSheet.CreateStyleRule(style, Nothing, selector)
End Sub
I'm sort of lost but well from what I understand, you want to set all menu items to the same sizes. Some got pictures and if you set a standar size the image repeats itself. Am I doing ok for now?
if that is your problem you need to set a value, 250px for the width or set the width to Auto. If you are using the image as the background for the menu then set
the property for the image : background-repeat:no-repeat . If its just a plain image it should not repeat itself, but if it does try and look for something similar where u can take out the repeat attribute.
siraero
Member
419 Points
608 Posts
Problem with style.Width = Unit.Pixel for sitemap/masterpage
Feb 05, 2012 05:05 PM|LINK
Hi
I have a menu from a sitemap file that im showing on a master page, its working fine, the only problem i have is that not all my imagelink have the same width.

If i changes the style.Width = Unit.Pixel to 100% then all the link have the same width as the first link
So u can see that if the image is smaller then the first one, then it will repeat it self and if its to big then the first one then some of the image is missing.
If i changes the width to maybe 250, then its easy to see that the images is repeating it self.

How can i get the style.Width = Unit.Pixel to use the right width of the image(s) !?
can i some place write the 6 images width !?
My code is
Protected Sub navcontainer_MenuItemDataBound(sender As Object, e As System.Web.UI.WebControls.MenuEventArgs) Handles navcontainer.MenuItemDataBound Dim map = CType(e.Item.DataItem, SiteMapNode) 'get SiteMapNode Dim css = map("css") 'cache cssclass, used several places in this method classes(e.Item) = css 'place css in lookup variable for use in DynamicItemTemplate Dim style As BGImageStyle Dim selector = String.Format(".{0}", css) If e.Item.Selected Then style = New BGImageStyle(map("imgActive")) 'use active image for selected page style.Width = Unit.Pixel(250) style.Height = Unit.Pixel(46) Page.Header.StyleSheet.CreateStyleRule(style, Nothing, selector) Else style = New BGImageStyle(map("imgLink")) 'use default image for not selected page selector = String.Format(".{0}", css) style.Width = Unit.Pixel(250) style.Height = Unit.Pixel(46) Page.Header.StyleSheet.CreateStyleRule(style, Nothing, selector) End If style = New BGImageStyle(map("imgHover")) selector = String.Format(".{0}:hover", css) style.Width = Unit.Pixel(250) style.Height = Unit.Pixel(46) Page.Header.StyleSheet.CreateStyleRule(style, Nothing, selector) End SubGindy39
Member
246 Points
99 Posts
Re: Problem with style.Width = Unit.Pixel for sitemap/masterpage
Feb 13, 2012 07:06 PM|LINK
I'm sort of lost but well from what I understand, you want to set all menu items to the same sizes. Some got pictures and if you set a standar size the image repeats itself. Am I doing ok for now?
if that is your problem you need to set a value, 250px for the width or set the width to Auto. If you are using the image as the background for the menu then set
the property for the image : background-repeat:no-repeat . If its just a plain image it should not repeat itself, but if it does try and look for something similar where u can take out the repeat attribute.
siraero
Member
419 Points
608 Posts
Re: Problem with style.Width = Unit.Pixel for sitemap/masterpage
Feb 24, 2012 11:00 AM|LINK
I only added
style.Width = Unit.Pixel(map("imgSize"))
and the in the web.sitemap file i added imgSize="SIZE VALUE" for every image
and its works like it need to...