Search code examples
c#asp.netasp-literal

Using asp:Literal text in html attributes


quick question. Is there a way to use asp:Literal text in an HTML attribute?

Example

<asp:Literal Text="hidden" runat="server" ID="ClassTag"></asp:Literal>

<tr class='<%= ClassTag %>' run="server" > </tr>

I am working on an overall solution to a repeater table row collapsing problem (asp:repeater collapsing table rows) for context, and this is perhaps the last thing I'm stuck on.

Please let me know. Thanks!


Solution

  • Not really, but are you just trying to set the class on the TR from code?

    In that case, write the following the ASP.NET:

    <tr runat="server" ID="CustomRow">
    

    And in the codebehind set the class through the Attributes collection:

    CustomRow.Attributes.Add("class", "[desired css class]");