Use in C # in html to execute if statement

Earlier, I saw Stackoverflow answers that use the “C # construct” to essentially execute the “if” statement in the html of an asp.net page.

So imagine that I want to display Eval ("option1") if it is not null OR Eval ("option2") if parameter 1 is NULL. How to do it?

Hope this makes sense ....

Many thanks!!!!

+4
source share
2 answers

You do not need an if statement for this. Just use

<%= Eval("option1") ?? Eval("option2") %> 
+10
source

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

 <% if (condition == true) { %> Show something <% } else { %> Show something else <%} %> 
+17
source

Source: https://habr.com/ru/post/1342006/


All Articles