If I have a UserControl like this:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Foo.ascx.cs" Inherits="Foo" %>
<asp:TextBox runat="server" ID="TxtFoo" />
And I include it into my page as follows:
...
<uc:Foo runat="server" ID="UcFoo" />
...
I would like to have my UserControl being wrapped inside a DIV with the ClientID as follows:
<div id="ctl00$ContentPH$UcFoo">
<input type="text" name="ctl00$ContentPH$UcFoo$TxtFoo" id="ctl00$ContentPH$UcFoo$TxtFoo" />
</div>
But actually I’m getting the content without the DIV tag. So the question here is: How can I tell ASP.NET to render my control inside a DIV with the auto-generated ClientID?
Wrap the contents of your UserControl inside a
<div>with anidattribute:Note that the
ClientIDwill contain underscores, not dollar signs (as in your example).