Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:05:22+00:00 2026-06-02T07:05:22+00:00

How do I determine if the checkbox is checked or not checked? Very perplexed

  • 0

How do I determine if the checkbox is checked or not checked?
Very perplexed why this is not working – it is so simple!

On my web form:

<asp:CheckBox ID="DraftCheckBox" runat="server" Text="Save as Draft?" />
<asp:Button ID="PublishButton" runat="server" Text="Save" CssClass="publish" />

Code behind which runs in the click event for my save button:

 void PublishButton_Click(object sender, EventArgs e)
{
    if (DraftCheckBox.Checked)
            {
                newsItem.IsDraft = 1;
            }
}

When debugging it never steps into the If statement when I have the checkbox checked in the browser. Ideas?!

I think there maybe some other code affecting this as follows…

In Page_load I have the following:

PublishButton.Click += new EventHandler(PublishButton_Click);

if (newsItem.IsDraft == 1)
    {
        DraftCheckBox.Checked = true;
    }
    else
    {
        DraftCheckBox.Checked = false;
    }

newsItem is my data object and I need to set the checkbox checked status accordingly.
When the save button is hit I need to update the IsDraft property based on the checked status of the checkbox:

void PublishButton_Click(object sender, EventArgs e)
{
    if (IsValid)
    {
        newsItem.Title = TitleTextBox.Text.Trim();
        newsItem.Content = ContentTextBox.Text.Trim();
        if (DraftCheckBox.Checked)
        {
            newsItem.IsDraft = 1;
        }
        else
        {
            newsItem.IsDraft = 0;
        }

        dataContext.SubmitChanges();
    }
}

So, isDraft = 1 should equal checkbox checked, otherwise checkbox should be un-checked. Currently, it is not showing this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:05:23+00:00Added an answer on June 2, 2026 at 7:05 am

    For me the best solution in the end has been to create 2 separate pages: 1 for editing a news articles & 1 for a new news article. So Ill never then be in the position of a new news data object being created when the page reloads.

    Both page return to the article index list page when the save button is pressed and that seems to work with being able to save the state of the draft checkbox and then show the state on the edit page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Default.aspx; <form id=form1 runat=server action=Default2.aspx method=post> <input type=checkbox name=change id=change/> </form> Default2.aspx.cs string ismultiple
I use this code to determine checkbox width and height: var chk = $('input[type=checkbox]:first');
In ASP.NET CheckBoxList is there any way to determine of a particular checkbox is
I need a way to programatically determine if this checkbox in control panel is
How do I determine the state of a checkbox (i.e. checked or unchecked) with
I want to iterate over checkboxes div and determine if checkbox1,checkbox2,checkbox3 are checked //
I just want to have php determines whether a checkbox is checked, but I
I'm generating an unknown amount of checkboxes in my form using mysql, this number
How would I use jQuery to determine if a checkbox or radio button is
In an ASP:ListView control, I have a checkbox for each row. Each row represents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.