为什么我的代码隐藏没有效果并且我的断点没有到达?
我的 WebForm1.aspx 文件中有这个:
<asp:checkbox id="ckbxAllGenres" runat="server" Checked="True" OnCheckedChanged="ckbxAllGenres_CheckedChanged" />
<label for="ckbxAllGenres">All</label>
<asp:checkbox id="ckbxAction" runat="server" />
<label for="ckbxAction">Action</label>
<asp:checkbox id="ckbxAdventure" runat="server" />
<label for="ckbxAdventure">Adventure</label>
WebForm1.aspx.cs 文件中的事件处理程序是:
protected void ckbxAllGenres_CheckedChanged(object sender, EventArgs e)
{
bool allGenresChecked = ckbxAllGenres.Checked;
ckbxAction.Checked = allGenresChecked;
ckbxAdventure.Checked = allGenresChecked;
. . .
我在第一行有一个断点(对布尔的赋值)。
检查 ckbxAllGenres 控件时未到达断点;因此,当然,代码没有运行,也没有任何反应。
确实,事件处理程序指示“0 个引用”,但为什么会这样呢?
WebForm1.aspx 的第一行是:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Flix4Fams_WebForms.WebForm1" %>