I have a UserControl that works much like an `<asp:Panel>`.

While a panel can do this:

```
<asp:Panel runat="server">
    <img src='<%= ResolveUrl("~/img.png")%>' />
</asp:Panel>

```

I get an error when trying this with my control:

```
<uc1:NotPanel runat="server">
    <img src='<%= ResolveUrl("~/img.png")%>' />
</uc1:NotPanel>

```

> 
> error: Code blocks are not supported in this context
> 
> 
> 

NotPanel is referenced like so:

```
<%@ Register Src="~/Controls/NotPanel.ascx" TagName="NotPanel" TagPrefix="uc1" %>

```

and defined as follows (this is a grossly stripped-down version):

```
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="NotPanel.ascx.cs" Inherits="MyNamespace.NotPanel" %>
<div class="something">
    <asp:PlaceHolder ID="phControls" runat="server" />
</div>

```

with this code-behind:

```
[ParseChildren(true, "Content")]
[PersistChildren(false)]
public partial class NotPanel : System.Web.UI.UserControl
{   
    [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
    public Control Content { get; set; }

    public void Page_Init(object sender, EventArgs e)
    {
        phControls.Controls.Add(Content);
    }
}

```

Have I done something wrong with the definition of this class, that I can't use code blocks? Or is this a limitation of UserControls?

A related issue (presumably with the same cause) occurs when a textbox is placed inside one of these controls - an `<asp:CompareValidator>` that is *not* inside the same control cannot reference it, without getting the following error:

> 
> Unable to find control id 'txtCompareTo' referenced by the 'ControlToCompare' property of 'compareValidator'.
> 
> 
> 

Again, this works fine when `<uc1:NotPanel>` is replaced with `<asp:Panel>`. Is there anything that can be done to make this work?