开发者

Use to c# in html to perform if statement

开发者 https://www.devze.com 2023-02-14 04:25 出处:网络
I\'ve previously seen answers on Stackoverflow that involve using \'the c# construct\' to essentially perform an \'if\' statement in the html of a开发者_StackOverflow社区 asp.net page.

I've previously seen answers on Stackoverflow that involve using 'the c# construct' to essentially perform an 'if' statement in the html of a开发者_StackOverflow社区 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!!!!


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

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


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

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

精彩评论

暂无评论...
验证码 换一张
取 消