在aspx使用if else 判断是否显示内容

来源:互联网 发布:excel数据批量打印 编辑:程序博客网 时间:2024/05/17 15:56
<%@ Page Language="C#" CodeFile="UseIfInAspx.aspx.cs" Inherits="UseIfInAspx" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Use if</title></head><body>    <form id="form1" runat="server">    <div>    <table>    <%if (Temp1 == "Temp1")      { %>       <tr>    <td><input type ="text" name ="txt_Temp1" value ="Temp1" runat ="server" style ="background-color :Red " /></td>    </tr>    <%}      else      { %>    <tr>    <td >    <input type ="button" name="btn_Temp2" value ="Temp2" runat ="server" />    <%} %>    </td>    </tr>    </table>       </div>    </form></body></html>