承接上篇,我們探討如何讓使用者擁有最大彈性自訂表單外觀。最終的表單樣板檔案(.ascx 或 .html)結構如下,採用純 HTML + CSS 設計,並預留 <asp:PlaceHolder> 作為動態控件注入點:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<style type="text/css">
<!--
.STYLE3 { font-family: "宋體"; font-size: 12px; }
.STYLE4 { font-family: "宋體"; font-size: 24px; font-weight: bold; }
.STYLE6 { font-family: "幼圓"; font-size: 36px; }
-->
</style>
</head>
<body>
<font size="+3"><asp:PlaceHolder runat="server" ID="__RowName"></asp:PlaceHolder> <!-- 標題 --></font>
<hr />
<table width="730" border="0" cellpadding="0" cellspacing="0" class="STYLE3">
<tr>
<td align="center">(發布:<asp:PlaceHolder runat="server" ID="__Text1"></asp:PlaceHolder> <!-- 發布人 --> 時間:<asp:PlaceHolder runat="server" ID="__Text2"></asp:PlaceHolder> <!-- 發布時間 -->)</td>
</tr>
<tr>
<td>
<asp:PlaceHolder runat="server" ID="__Content"></asp:PlaceHolder>
<!-- 新聞內容 -->
</td>
</tr>
</table>
</body>
</html>
美工人員可使用 Dreamweaver 等工具設計介面,僅需在特定位置放入雙底線開頭的 PlaceHolder(如 __RowName、__Content),系統即可於執行期識別並動態載入對應的輸入控件,實現「介面與邏輯完全分離」的開發模式。