Reputation: 13
I have a Repeater who contain an html link balise. I want both the attribute name and the text to be "..." if Eval("Name")==null or Eval("Name") instead. So I try to do this :
<a runat="server" class="a_equipement" onserverclick="displayEquipment" name='<%= Eval("Nom")%> == null ? "..." : <%# Eval("Nom")%>'> <%= Eval("Nom");%> == null ? "..." : <%# Eval("Nom");%> </a>
But it didn't work and I got a weird error : "DC6_Configuration_Equipement.aspx(42,214): error CS1026: ) expected"
Is it possible to do it like this or are there other possibilities ?
After some research I try this :
name='<%# Eval("Nom") == null ? "..." : Eval("Nom")%>'
But same probleme again... I work on IE8, could it be compability issues ?
Thank's again for all your answer :)
Upvotes: 0
Views: 739
Reputation: 35514
Use it like this. Then it will also work if Nom
is ""
:
<a runat="server" name='<%# string.IsNullOrEmpty(Eval("Nom").ToString()) ? "..." : Eval("Nom") %>'><%# string.IsNullOrEmpty(Eval("Nom").ToString()) ? "..." : Eval("Nom") %></a>
The compatibility with IE 8 has nothing to do with the ternary operator itself.
Upvotes: 1