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 :)
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.