<script language="c#" runat="server">
void chkLayout_CheckedChanged(Object sender,EventArgs e){
if( chkLayout==true ){//第十行
MyLover.RepeatLayout = RepeatLayout.Table;
}
else{
MyLover.RepeatLayout = RepeatLayout.Flow;
}
}
</script>
<body>
<form runat="server">
<asp:CheckBoxList id="MyLover"
runat="server"/>
<asp:ListItem>范冰冰</asp:ListItem>
<asp:ListItem>张柏芝</asp:ListItem>
<asp:ListItem>梁咏琪</asp:ListItem>
<asp:ListItem>张曼玉</asp:ListItem>
<asp:ListItem>梅艳芳</asp:ListItem>
<asp:ListItem>张国荣</asp:ListItem>
</asp:CheckBoxList>
<br>jjjj
<br>
<asp:CheckBox id="chkLayout" OnCheckedChanged="chkLayout_CheckedChanged" AutoPostBack="true" Text="显示表格布局" Checked="True"></asp:CheckBox>
<br>
<asp:CheckBox id="chkDirection" OnCheckedChanged="chkDirection_CheckedChanged" Text="水平显示"></asp:CheckBox>
</form>这一个会提示错误:
第十行   The name 'chkLayout' does not exist in the class or namespace 'ASP.test_aspx'

解决方案 »

  1.   

    修改了以后,仍然出现错误:
    The type or namespace name 'chkLayout' could not be found (are you missing a using directive or an assembly reference?)
      

  2.   

    仍然错误:
    The type or namespace name 'chkLayout' could not be found (are you missing a using directive or an assembly reference?)
      

  3.   

    谢谢解决了,体会:
    在写ASP.Net中的空间的时候,一定不要忘了runat="server"
    因为ASP.Net中有两种类型的控件一是HTML Server Control 一是Web Server Control,通过名字我们也可以看出  server第一个错误chkLayout==true ,哎,我经常犯的:)
      

  4.   

    不好意思,其实上边还有一个错误:
     <asp:CheckBoxList  id="MyLover"  
                                                                                                          runat="server"/>  //不能加  "/"
              <asp:ListItem>范冰冰</asp:ListItem>  
              <asp:ListItem>张柏芝</asp:ListItem>  
              <asp:ListItem>梁咏琪</asp:ListItem>  
              <asp:ListItem>张曼玉</asp:ListItem>  
              <asp:ListItem>梅艳芳</asp:ListItem>  
              <asp:ListItem>张国荣</asp:ListItem>  
    </asp:CheckBoxList>  
      

  5.   

    <asp:CheckBoxList id="MyLover" runat="server">
    <asp:ListItem value="范冰冰">范冰冰</asp:ListItem>
    <asp:ListItem value="张柏芝">张柏芝</asp:ListItem>
    <asp:ListItem value="梁咏琪">梁咏琪</asp:ListItem>
    <asp:ListItem value="张曼玉">张曼玉</asp:ListItem>
    <asp:ListItem value="梅艳芳">梅艳芳</asp:ListItem>
    <asp:ListItem value="张国荣">张国荣</asp:ListItem>
    </asp:CheckBoxList>