-2

I am using an eval statement to display a string from a column value. Everything is setup fine in that regard, but when I put it into a bit of HTML, my text vanishes. Any ideas?

<ItemTemplate>
    <i class="fa fa-exclamation-circle offense-icon added-hours" id="Offense_1" <%# Eval("OFFENSE").ToString() == "" ? "hidden" : "" %>></i>
    <div id="addedDescription1" class="added-hours-description hide-description">
        <%# Eval("OFFENSE") %>
    </div>
</ItemTemplate>

Browser HTML:

<td>
    <i class="fa fa-exclamation-circle offense-icon added-hours" id="Offense_1" ></i>
    <div id="addedDescription1" class="added-hours-description hide-description">
        Missing Document
    </div>
</td>

Hide description CSS:

.hide-description {
    visibility: hidden;
    overflow: hidden;
    position: absolute;
    bottom: 0;
    right: 0;
}
dtlvd
  • 457
  • 1
  • 8
  • 21
Connor Mackay
  • 77
  • 1
  • 1
  • 11
  • What is the exact rendered html for this template when you check your browser's View Source? – Joel Coehoorn Apr 04 '18 at 15:37
  • 1
    What does the `hide-description` CSS do? – Ron Beyer Apr 04 '18 at 15:45
  • @JoelCoehoorn Added the browser side html to the OP. – Connor Mackay Apr 04 '18 at 16:46
  • @RonBeyer Added the CSS to OP. Wasn't done by me but plain text displays in there fine. – Connor Mackay Apr 04 '18 at 16:49
  • What's the point of using a css class containing `visibility: hidden` and expecting it to be displayed? Is this proposital or you didn't realize what the css was doing? – Alisson Reinaldo Silva Apr 04 '18 at 16:57
  • I have a bit of JS to toggle the class on click so it acts like a pop up. Works as intended with plain text but not an Eval statement. – Connor Mackay Apr 04 '18 at 16:59
  • To be clear, is the HTML in the "Browser HTML" section of your question the actual, rendered HTML that your browser sees? If so, I don't see how the `Eval` is even relevant. –  Apr 04 '18 at 17:13
  • The `id` attribute on your `div` won't be unique unless your template is rendered only once. That's invalid HTML. –  Apr 04 '18 at 17:14
  • @ConnorMackay, Eval is running at server side, not in your browser. As long it returns a text the browser would handle it as any other content. – derloopkat Apr 04 '18 at 17:17
  • I can put an Eval Statement and a plaintext word in the itemtemplate for this div. When I click the icon, the plaintext work appears, but not the Eval statement restult. – Connor Mackay Apr 04 '18 at 17:19
  • When I put in the Eval without the hidden div, it returns what im expecting / : – Connor Mackay Apr 04 '18 at 17:24
  • I don't believe your issue is related to the `Eval()` at all. –  Apr 04 '18 at 20:19

1 Answers1

0

The text is there. You need to remove the hide-description css class from the div to be able to see it.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • Its hidden and I have a bit of JS to toggle the class when the icon is clicked. I want it to be hidden until it is clicked and this works fine with plain text but not the Eval statement. – Connor Mackay Apr 04 '18 at 16:56