问题
I have a user control (gallery.ascx
) and I want to use the photo.ascx
control in the gallery control. I've added this register at the top of gallery.ascx
, but it still can't find photo:
<%@ Register TagPrefix="ssctrl" TagName="photo" Src="controls/photo.ascx" %>
Any ideas?
回答1:
In case anyone is wondering, the Register is correct, my photo user control tag was just not formed properly. I did have it as:
<ssctrl:photo ID="Photo" Key="<%# Eval("PageTemplatePK") %>" runat="server" />
and the Key property needed to use single quotes instead of double quotes because it was using an Eval expression:
<ssctrl:photo ID="Photo" Key='<%# Eval("PageTemplatePK") %>' runat="server" />
After that, it worked.
来源:https://stackoverflow.com/questions/251289/how-do-i-use-an-asp-net-user-control-in-another-user-control