简体   繁体   English

如何在另一个用户控件中使用asp.net用户控件?

[英]How do I use an asp.net user control in another user control?

I have a user control ( gallery.ascx ) and I want to use the photo.ascx control in the gallery control. 我有一个用户控件( gallery.ascx ),我想在库控件中使用photo.ascx控件。 I've added this register at the top of gallery.ascx , but it still can't find photo: 我在gallery.ascx的顶部添加了这个寄存器,但它仍然无法找到照片:

<%@ Register TagPrefix="ssctrl" TagName="photo" Src="controls/photo.ascx" %>

Any ideas? 有任何想法吗?

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: 和Key属性需要使用单引号而不是双引号,因为它使用的是Eval表达式:

<ssctrl:photo ID="Photo" Key='<%# Eval("PageTemplatePK") %>' runat="server" />

After that, it worked. 在那之后,它奏效了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM