|
|
Rank: Newbie
Joined: 10/23/2008 Posts: 2 Location: Stockholm, Sweden
|
Hello!
I'm new to Umbraco so my problem has probably an easy answer.
I try to make a menu as a UserControl and use the asp:repeater. My code looks like this (just the importent stuff)
Menu.ascx.cs
protected void Page_Load(object sender, EventArgs e) { // Get top-level-node Node n = Node.GetCurrent(); while (n.Parent != null) n = n.Parent;
repMenu.DataSource = n.Children; repMenu.DataBind(); }
Menu.ascx
<asp:repeater id="repMenu" runat="server"> <headertemplate><ul class="mainlevel" /></headertemplate> <itemtemplate> <li> <!-- NiceUrl:<%# Eval("NiceUrl") %>; Name:<%# Eval("Name") %>; Id:<%# Eval("Id") %>--> <a href="<%# Eval("NiceUrl") %>"><%#Eval("Name") %></a> <asp:hyperlink navigateurl='<%# Eval("NiceUrl") %>' text='<%#Eval("Name") %>' runat="server" /> </li> </itemtemplate> <footertemplate></ul></footertemplate> </asp:repeater>
output:
<li> <!-- NiceUrl:; Name:Dart; Id:1053--> <a href="/dart.aspx">Dart</a> <a href="/dart.aspx">Dart</a> </li>
As you can see in the output the first NiceUrl is empty! If i move around the three lines inside the <li>-tags it´s always the 1st that is empty and the other two looks good.
Has someone seen this?
BTW, I´m using Umbraco 4 Beta 1.
Regards -Johan
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Hi johan, I don't see any added value from using a user control over using a simple xslt that does exactly the same: - No user input required. - Number of lines is rather limited, makes it a perfect candidate for xslt processing. - Caching (I know, you could also use caching with user controls, but not the way you're using it atm) Hope that helps. Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Devotee
Joined: 10/20/2008 Posts: 83 Location: USA
|
Hi Johan, (fran en landsman fran sverige) I think the best thing for you to do is use one of the preexisting XSLT templates that comes with Umbraco. There are several to choose from, but changes are that you will be using one of the following: - List Sub Pages by Level; or - List Sub Pages from current page In addition to reviewing these templates you may also want to review this excellent book (this actually helped me a lot last night), depending on your skills with XSLT: http://www.umbraco.org/documentation/books/xslt-basics/xpath-axes-and-their-shortcutsThis will help you traverse the XML document to find the nodes that you are looking for. Hope this helps. Cheers, Nik
Level 1 Certified / www.scandiaconsulting.com
|
|
Rank: Newbie
Joined: 10/23/2008 Posts: 2 Location: Stockholm, Sweden
|
Hello!
Thank you for your help. I appreciate your suggestions of a better solution to what I want to do, then the one I've chosen. I will look into this XSLT templates.
I will start with the book "XSLT Basics" :)
Regards -Johan
|
|
 Rank: Devotee
Joined: 10/20/2008 Posts: 83 Location: USA
|
Great, good luck and give a shout if you would like a second pair of eyes to review the XSLT (not that I am a master at it yet, but sometimes its the little things...). Lycka till! -- Nik
Level 1 Certified / www.scandiaconsulting.com
|
|
|
Guest |