I'm trying to run the templated user control example provided by MSDN. Code is as follows:
So according to MSDN this should implement as follows:
<%@ Register Assembly="MyAssembly" Namespace="MyAssembly.Controls" TagPrefix="abs" %>
<abs:TemplatedFirstControl id = "First" runat=server
Text= "The time on the server is " >
<FirstTemplate>
<h3><font face="Verdana" color = "red">
<%# Container.Text %> <%# Container.DateTime %>
</font>
</h3>
</FirstTemplate>
</abs:TemplatedFirstControl>
Designer complains that content is not allowed between the opening and closing tags of TemplatedFirstControl
and that FirstTemplate
is not supported. So what's missing? I duplicated MSDN's code verbatim
MSDN Article: http://msdn.microsoft.com/en-us/library/aa720695%28v=VS.71%29.aspx
For anyone who has the same problem, I found that adding the following attributes to the FirstTemplate property solved the issue for me:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public ITemplate FirstTemplate
{
get
{
return firstTemplate;
}
set
{
firstTemplate = value;
}
}
It sounds like the compiler is not recognizing that FirstTemplate is a valid child element of TemplatedFirstControl. Check the following:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.