I have a usercontrol that I am trying to use in a project.
If I do it like this (reference the sitemap in the control)
<%@ Register TagPrefix="OS" Namespace="OS_Layouts" Assembly="OSControlLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=0831306e55dc1c27" %>
<html><body>
<OS:OSmenu runat="server" ID="men1" SiteMap="siteMapDataSource1" />
<asp:SiteMapDataSource ShowStartingNode="false" SiteMapProvider="CombinedNavSiteMapProvider"
ID="siteMapDataSource1" runat="server" />
</body </html>
I get an odd error.
Parser Error Message: Cannot create an object of type 'System.Web.UI.WebControls.SiteMapDataSource' from its string representation 'siteMapDataSource1' for the 'SiteMap' property.
If I do this it works fine. (add the sitemap in code during pageload)
<%@ Register TagPrefix="OS" Namespace="OS_Layouts" Assembly="OSControlLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=0831306e55dc1c27" %>
<script runat=server>
protected void Page_Load(object sender, EventArgs e)
{
men1.SiteMap = siteMapDataSource1;
}
</script>
<html><body>
<OS:OSmenu runat="server" ID="men1" />
<asp:SiteMapDataSource ShowStartingNode="false" siteMapProvider="CombinedNavSiteMapProvider" ID="siteMapDataSource1" runat="server" />
</body> </html>
The only "clever" thing I am doing is using 'aspnet_compiler' and 'aspnet_merge' to create a .dll containing my usercontrols into a single dll I can use in other projects.
Have I misunderstood, or misconfigured something?
Thanks EDIT: some further info.
So my aspx.cs looks like this I always get "Fail!"
using System;
using System.Web.UI.WebControls;
public partial class OSmenu : System.Web.UI.UserControl
{
public String SiteMapID { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (SiteMapID == "") return;
SiteMapDataSource foo = Page.FindControl(SiteMapID) as SiteMapDataSource;
if (foo == null)
{
Response.Write("</br> fail!");
}
else
{
Response.Write("/<br> ok!" + foo.UniqueID);
}
}
}
All this is slightly complicated by the fact the host page for the control is a sharepoint masterpage, and I cannot get debugging to work for the control, I can for the masterpage itself!