josh josh - 1 year ago 164
ASP.NET (C#) Question

Forms checkbox.Checked not recognised

I'm having troubles with recognizing

. I'm getting this error

'HtmlGenericControl' does not contain a definition for 'Checked' and
no extension method 'Checked'

Which namespace am I missing/not have to use the .Checked property?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Clip
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;
Checkbox1.Visible = false;
Checkbox1.Checked = false;

Answer Source

Use ASP checkbox instead of Html input type checkbox

<asp:CheckBox ID="CheckBox1" runat="server" oncheckedchanged="CheckBox1_CheckedChanged" AutoPostBack="true" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download