C
Chris
Hi all,
i want to create a usercontrol that I can use in my pages in a similar
way to the Label control:
<asp:Label ID="lblUserName" runat="server"><%=User.Name%></asp:Label>
I have created a usercontrol that allows text in between the start and
end tag, which works fine, however I cannot place a code-block in
there, as I will get the following error:
Parser Error Message: Code blocks are not supported in this context.
This is the actual content in my usercontrol.ascx:
-----------------------------------------------------------------------
<asp:Image ID="imgMain" runat="server" ImageUrl="~/Images/Icons/emblem-
important.png" />
this is the actual code in my usercontrol.ascx.cs:
---------------------------------------------------------------------------
[ParseChildren(true, "InnerHTML")]
[PersistChildren(true)]
public partial class Include_UserControls_Error_Indicator :
System.Web.UI.UserControl
{
[PersistenceMode(PersistenceMode.InnerProperty)]
public string InnerHTML { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
imgMain.ToolTip = InnerHTML;
}
}
and this is how I want to use the usercontrol on my page:
-----------------------------------------------------------------------------------
<uc:Error_Indicator runat="server"><%=ErrorMessage %></
uc:Error_Indicator>
I am able to use it like this, however this is not how i want to use
it:
i want to create a usercontrol that I can use in my pages in a similar
way to the Label control:
<asp:Label ID="lblUserName" runat="server"><%=User.Name%></asp:Label>
I have created a usercontrol that allows text in between the start and
end tag, which works fine, however I cannot place a code-block in
there, as I will get the following error:
Parser Error Message: Code blocks are not supported in this context.
This is the actual content in my usercontrol.ascx:
-----------------------------------------------------------------------
<asp:Image ID="imgMain" runat="server" ImageUrl="~/Images/Icons/emblem-
important.png" />
this is the actual code in my usercontrol.ascx.cs:
---------------------------------------------------------------------------
[ParseChildren(true, "InnerHTML")]
[PersistChildren(true)]
public partial class Include_UserControls_Error_Indicator :
System.Web.UI.UserControl
{
[PersistenceMode(PersistenceMode.InnerProperty)]
public string InnerHTML { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
imgMain.ToolTip = InnerHTML;
}
}
and this is how I want to use the usercontrol on my page:
-----------------------------------------------------------------------------------
<uc:Error_Indicator runat="server"><%=ErrorMessage %></
uc:Error_Indicator>
I am able to use it like this, however this is not how i want to use
it: