문제

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