<script language="c#" runat="server">
void Page_Load()
{
public string BackColor = "darkblue";
}
</script><html>
<body>
<table style="background-color:<%=BackColor%>" width="100%" cellpadding="10" cellspacing="0">
<tr>
<td>
Welcome to the shop!!!
</td>
</tr>
</table>
</body>
</html>定义了这么一个组件,但是当也面调用他时会出现如下错误:
Compiler Error Message: CS1513: } expectedSource Error: Line 1:  <script language="c#" runat="server">
Line 2:   void Page_Load()
Line 3:   {
Line 4:   public string BackColor = "darkblue";
Line 5:   }
 
但是当我把上面的改为:
<script language="c#" runat="server">
     public string BackColor = "darkblue";
</script>时就可以了,这是为什么?
这样的话当我在组件中需要有一个onclick事件时调用函数就一直出错了,怎么办啊?
求救!!!!!