aspx页面中的if语句 [英] If statement in aspx page
本文介绍了aspx页面中的if语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的网站上编写一个基本的 if 语句,根据变量是否设置为 true 来显示第 1 项或第 2 项.
I want to write a basic if statement on my site to display either item 1 or item 2 depending on if a variable is set to true.
我对 .NET 不太熟悉,需要一些关于如何让 if 语句在 aspx 页面上工作的基本结构的帮助
I'm not too familiar with .NET and need a little help with the basic structure of how to get an if statement to work on the aspx page
推荐答案
如果目的是显示或隐藏页面的一部分那么你可以做以下事情
if the purpose is to show or hide a part of the page then you can do the following things
1) 用
<% if(somecondition) { %>
some html
<% } %>
2) 将部件包装在 Panel 控件中,并在代码隐藏中使用 if 语句设置 Panel 的 Visible 属性.
2) Wrap the parts in a Panel control and in codebehind use the if statement to set the Visible property of the Panel.
这篇关于aspx页面中的if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文