Use to c# in html to perform if statement

耗尽温柔 提交于 2019-12-06 03:03:34

问题


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


回答1:


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

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



回答2:


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

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


来源:https://stackoverflow.com/questions/5169665/use-to-c-sharp-in-html-to-perform-if-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!