我在识别.Checked
时遇到了麻烦。我收到此错误
'HtmlGenericControl'不包含'Checked'和。的定义 没有扩展方法'已检查'
我缺少哪个命名空间/不必使用.Checked属性?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Radio1_SelectedIndexChanged(object sender, EventArgs e)
{
if (Radio1.SelectedIndex == 0)
{
Checkbox1.Visible = true;
}
else
{
Checkbox1.Visible = false;
Checkbox1.Checked = false;
}
}
}
}
答案 0 :(得分:1)
使用ASP
复选框代替Html输入类型checkbox
<asp:CheckBox ID="CheckBox1" runat="server" oncheckedchanged="CheckBox1_CheckedChanged" AutoPostBack="true" />
答案 1 :(得分:0)
我猜你没有为radiobutton list设置属性Autopostback =“true”。
<asp:RadioButtonList ID="RadioButtonList1" runat="server" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="1" Text="1"> </asp:ListItem>
<asp:ListItem Value="2" Text="2"> </asp:ListItem>
</asp:RadioButtonList>
<asp:CheckBox ID="CheckBox1" runat="server" />