Use to c# in html to perform if statement

22,008

Solution 1

You don't need if statement for it. Just use

<%= Eval("option1") ?? Eval("option2") %>

Solution 2

Is this the "if" semantics you are looking for?

<% if (condition == true) { %>
  Show something
<% } else { %>
  Show something else
<%} %>
Share:
22,008
Phill Healey
Author by

Phill Healey

Phill hat sich schon seit den Kindertagen des Internet mit Design und Erstellung von Webseiten beschäftigt. Als Teenager, der sich das Programmieren selber beigebracht hat, erstellte er mit seinem Taschengeld einen der weltweit ersten Internet Radiosender, auf einem alten 8MHz PC und mit einem Einwahl-Modem. Die Webseite wurde damals in den Top 10.000 Seiten im Web genannt. Seitdem hat Phill ein Studium in Mutimedia &amp; Internet Technologie mit einem Einser abgeschlossen und mit einer Anzahl an Agenturen in Manchester und London gearbeitet. Dort was er mit der Erstellung und Pflege von Webseiten für IBM sowie einer der weltweit führenden Flugzeugvertriebsfirmen betreut. Seit einigen Jahren hat Phill sich auch der Erstellung von Webseiten in WordPress zugewandt und ist mittlerweile ein Experte was CMS und SEO angeht.

Updated on July 05, 2022

Comments

  • Phill Healey
    Phill Healey almost 2 years

    I've previously seen answers on Stackoverflow that involve using 'the c# construct' to essentially perform an 'if' statement in the html of a asp.net page.

    So imagine i want to display Eval("option1") if its not null OR Eval("option2") if option 1 is null. How do i do this???

    Hope that makes sense....

    Many Thanks!!!!