使用C#中的HTML if语句来执行 [英] Use to c# in html to perform if statement

查看:601
本文介绍了使用C#中的HTML if语句来执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我previously看到了使用C#的构造在一个asp.net页面的HTML本质上执行一个'如果'语句涉及#1的答案。

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.

所以,想象一下,我想如果它不是null或评估和演示来显示的eval(选项1)(选项2),如果选择1为空。我该怎么做?这

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

非常感谢!!!!

推荐答案

您不需要if语句它。只需使用

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

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

这篇关于使用C#中的HTML if语句来执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆