Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use to c# in html to perform if statement

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!!!!

like image 239
Phill Healey Avatar asked Mar 02 '11 15:03

Phill Healey


People also ask

What does -> mean in C?

An Arrow operator in C/C++ allows to access elements in Structures and Unions. It is used with a pointer variable pointing to a structure or union. The arrow operator is formed by using a minus sign, followed by the greater than symbol as shown below.

What does %d do?

%d takes integer value as signed decimal integer i.e. it takes negative values along with positive values but values should be in decimal otherwise it will print garbage value.

What is && operator in C?

The && (logical AND) operator indicates whether both operands are true. If both operands have nonzero values, the result has the value 1 . Otherwise, the result has the value 0 . The type of the result is int . Both operands must have an arithmetic or pointer type.


2 Answers

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

<% if (condition == true) { %>
  Show something
<% } else { %>
  Show something else
<%} %>
like image 173
Brian Genisio Avatar answered Sep 19 '22 16:09

Brian Genisio


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

<%= Eval("option1") ?? Eval("option2") %>
like image 41
Lloyd Avatar answered Sep 19 '22 16:09

Lloyd