Вопрос

I am inside a Repeater, and I'm trying to call the IsExperienced function from CssClass (as I usually do):

<asp:LinkButton 
    ID="CheckBox" 
    CssClass='wall-item-checkbox <%# IsExperienced() %>' 
    runat="server" 
    onclick="CallFunction">
    &nbsp;
</asp:LinkButton>

but this time it prints class=wall-item-checkbox <%# IsExperienced() %> on the HTML.

Это было полезно?

Решение

Seems like an odd approach in the first place given that you can access that control within the repeater ItemDataBound event, better to separate code from markup.

Why don't you do this instead:

protected void fooRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
    {
        LinkButton lnkButton = (LinkButton)e.Item.FindControl("CheckBox");
        lnkButton.CssClass += string.Format(" {0}", IsExperienced());
    }
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top