0

I'm having troubles with recognizing .Checked. 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 
{
    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;
            }
        }
    }
}
1
  • 1
    Show your aspx code. Use a real System.Web.UI.CheckBox instead of a HTML-control Commented Aug 26, 2016 at 12:47

2 Answers 2

1

Use ASP checkbox instead of Html input type checkbox

<asp:CheckBox ID="CheckBox1" runat="server" oncheckedchanged="CheckBox1_CheckedChanged" AutoPostBack="true" />
Sign up to request clarification or add additional context in comments.

1 Comment

Ahh damn, yes i just noticed that! thanks! will need to wait 6 mins before i can put this as an answer
0

I guess you didn't set the property Autopostback = "true" for radiobutton list.

 <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" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.