Thursday, September 27, 2007

New Feature ChildrenAsTable

Umbraco V3 offers many things! and one og them is you now have the posibillity to get you Nodes as a datatable object.
This is great if you love your Usercontrols, repeaters and databinding :)

Niels Hartvig have written an article about how to use the datatable "ChildrenAsTable"

Its a good article, but there is some confusion when you need to get the properties from a node.

Normally when you need a property you retrieves it with the alias, so I tried to make a simple test.
<asp:repeater id="Repeater1" runat="server"><itemtemplate> <a href="'<%#">'><%# Eval("NodeName")%></a> <%# ((DataRowView)Container.DataItem)["umbNaviHide"]%> </itemtemplate></asp:Repeater>

This gave me an error on the umbracoNaviHide, and I thougt whats was wrong with that?

After some debugging I found out that you needs to use the name of the property instead of the Alias, so it looks like this:

<asp:repeater id="Repeater1" runat="server"><itemtemplate>
<a href="'<%#">'><%#Eval("NodeName")%></a>
<%# ((DataRowView)Container.DataItem)["Hide in navigation"]%>
</itemtemplate>
</asp:Repeater>

And then it just worked :)

/Happy coding
Read Nielses article here
<a href="http://www.umbraco.org/documentation/books/what" target="_blank">http://www.umbraco.org/documentation/books/what's-new-in-v3/new-feature-nodefactory-as-datatable-object</a>

Sunday, September 23, 2007

MSBuild - What a tool

MSbuild is a great tool to do automatied stuff.

Introduction to <a href="http://www.codeproject.com/books/msbuild.asp" target="_blank">MSBuild</a>
I have used it for some time now on my Umbraco projects, and it really saves me alot of time.
In my project I create a MSBuild script that copies my assembly and usercontrols to my local website, every time i buíld my project.
so my debugging steps change from 7 to 5 steps.

1. Build Project
2. Copy assmbly files to bin folder on IIS [now Automated]
3. Copy ascx files to usercontrols folder on IIS [now Automated]
4. Open website in IE
5. Attach my project to w
6. Go to page that has to be debugged.
7. Find and solve problem.
My msBuld script:


<target name="PostBuildEvent">
<createitem include="$(ProjectDir)$(OutputPath)$(AssemblyName).dll">
<output taskparameter="Include" itemname="OutputFiles"></createitem>
<message text="Copying '%(OutputFiles.Filename)%(OutputFiles.Extension)' FooBar bin directory" importance="high">
<copy sourcefiles="@(OutputFiles)" destinationfolder="$(SolutionDir)bin" continueonerror="false" skipunchangedfiles="true">
</target>

Another way to use MSBuild is to have different configuration settings for production and testing environments read about it on <a href="http://weblogs.asp.net/scottgu/archive/2007/09/21/tip-trick-automating-dev-qa-staging-and-production-web-config-settings-with-vs-2005.aspx" target="_blank">Scott Gu's blog</a>