2

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!

David
  • 573
  • 7
  • 40
  • 1
    If the tr was not running on the server side, yes, you could. – Etienne Mermillod Jul 10 '17 at 16:55
  • Why is the `tr` running on the server anyway? It has no `ID` so it is unaddressable (except by walking control collections, but... ewww). Remove that and what you have should work fine if you also add the `.Text` property to `ClassTag`. – Bradley Uffner Jul 10 '17 at 17:57

1 Answers1

2

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]");
Paul-Jan
  • 16,746
  • 1
  • 63
  • 95