服務(wù)熱線
153 8323 9821
用 <%內(nèi)嵌代碼%>
比如 :
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>內(nèi)嵌代碼的用法</title>
</head>
<body>
<form id="form1" runat="server">
<%if(DateTime.Now.Hour<12)%>
上午好!
<%else%>
下午好!
</form>
</body>
</html>
問 :
<table border="1" style="width: 545px; height: 188px">
<tr>
<td>
<asp:Label ID="BODYLabel" runat="server" Text= <%# Eval("BODY") %> ></asp:Label></td>
</tr>
</table>
如果 RE_BODY不等于空那么顯示下面的回復(fù)內(nèi)容, // 這句話怎么寫?
<table border="1" style="width: 543px; height: 143px">
<tr>
<td>
<asp:Label ID="RE_BODYLabel" runat="server" Text= <%# Eval("RE_BODY") %> ></asp:Label></td>
</tr>
</table>
回答:
ASP.NET推薦是這樣寫:
<table border="1" style="width: 545px; height: 188px">
<tr>
<td>
<asp:Label ID="BODYLabel" runat="server" Text= <%# Eval("BODY") %> ></asp:Label></td>
</tr>
</table>
<table border="1" style="width: 543px; height: 143px" runat="server" Visibly= <%# Eval("RE_BODY") != null %> >
<tr>
&n