I can’t find a good article that solves my following issue, so if anyone has the answer or just a link to the answer I would be happy.
Let’s say I have created a UserControl called MyUserControl.ascx
I reg it in ascx with prefix uc
<uc:MyUserControl runat='server' id='uc_test' SomeProperty='true'> <InnerContent> ... Controls added in here.... <asp:Button runat='server' id='btn_test' Text='Test'> ... <InnerContent> </uc:MyUserControl>
I know how to create a usercontrol and how to add properties and events to it.
BUT how do I make the ‘InnerContent’ field in my usercontrol?
I have no clue so please be a little specific 🙂
Cheers
You usually don’t do that with user controls (
.ascx). It’s completely possible though. This is mostly done in custom controls you build using code files. To accomplish it, you declare your control class like:For
.ascxfiles you could inherit it fromUserControlinstead.Templating in ASP.NET is a rather complex thing. It’s not really possible to explain everything in an answer. You should look at some samples and documentation.