*.aspx页面的注释问题
从书上拷下如下代码在Vs.net中试运行。
<%@ Page Language="C#" %>
<script Runat="Server">
string strBackGroundColor = "white";
void dropColors_SelectedIndexChanged( object s, EventArgs e ) {
strBackGroundColor = dropColors.SelectedItem.Text;
}
</Script>
<html>
<head><title>DropDownListAutoPostBack.aspx</title></head>
<body bgcolor="<%=strBackGroundColor%>">
<form Runat="Server">
<asp:DropDownList
ID="dropColors"
AutoPostBack="True"
OnSelectedIndexChanged="dropColors_SelectedIndexChanged"
Runat="Server" >
<asp:ListItem text="Red" />
<asp:ListItem text="Green" />
<asp:ListItem text="Blue" />
</asp:DropDownList>
</form>
</body>
</html>
现在想把AutoPostBack="True"这一行注释掉,但怎么都不行。
变为<%--AutoPostBack="True"--%>是如下错误:
分析器错误
说明: 在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件。
分析器错误信息: 服务器标记不能包含 <% ... %> 构造。
源错误:
行 17: <form Runat="Server">
行 18:
行 19: <asp:DropDownList
行 20: ID="dropColors"
行 21: <%--AutoPostBack="True"--%>
变为<!--AutoPostBack="True"-->是如下错误:
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: CS0246: 找不到类型或命名空间名称“dropColors”(是否缺少 using 指令或程序集引用?)
源错误:
行 6:
行 7: void dropColors_SelectedIndexChanged( object s, EventArgs e ) {
行 8: strBackGroundColor = dropColors.SelectedItem.Text;
行 9: }
行 10:
实在是搞不懂,正确的注释方法应该是什么啊?望高人指点!!