How do I use an asp.net user control in another user control?
Asked Answered
L

1

6

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?

Lacewing answered 30/10, 2008 at 18:46 Comment(1)
Is it possible your gallery control is also in the controls folder, making the Src attribute incorrect?Torin
L
6

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.

Lacewing answered 30/10, 2008 at 18:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.