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 150839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:21:15+00:00 2026-05-11T09:21:15+00:00

Here is a simplified example of what I am trying to achieve; <asp:CheckBox runat=server

  • 0

Here is a simplified example of what I am trying to achieve;

<asp:CheckBox runat='server' Checked='<%# this.isChecked %>' id='myCheckBox' /> 

Then in my code behind;

public partial class _Default : System.Web.UI.Page  {     bool _isChecked = true;      public string isChecked     {         get         {             return _isChecked.ToString();         }     }      protected void Page_Load(object sender, EventArgs e)     {     } } 

I am aware that, in this case, I can simply use myCheckBox.Checked = true, but I’m just using this example for illustration purposes. The real control is a custom one, but I’m not having any luck getting this approach to work. It just seems to ignore the value I’m supplying.

Is it valid to use <%# this.isChecked %> in this manner?

EDIT:

Sorry, I wrote this in a hurry and realise that it’s not really clear that I intended ‘checkbox’ to just be an example. I’m just trying to get a server-side bool into any particular attribute of the ASP control, not necessarily the ‘checked’ attribute of the checkbox control.

EDIT 2: Updated my example to use string property rather than boolean field, but it is reporting the following error in my ASPX file now;

Cannot convert type ‘string’ to ‘bool’

  • 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. 2026-05-11T09:21:16+00:00Added an answer on May 11, 2026 at 9:21 am

    If you supply

    checked='anything'  

    it will be checked (in HTML). You need to omit the checked attribute for it to not be checked, so this will not work.


    After the edit to the question, here is my updated answer:

    I would not try to set the attribute in the aspx page, rather I would use the ID and do it in code.

    eg.

    <asp:Control ID='uxMyControl' runat='server' attributes='other'... /> 

    Code behind:

    private Boolean mypropery = false;  Page_Load(object sender, EventArgs e) {     this.myproperty = true;     uxMyControl.attributes = myproperty; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a simplified code example of what I'm trying to do: public class
I cannot find the solution for this problem, here is the simplified example: On
Here is an example of the structure I'm trying to achieve. I'll just setup
Here is a simplified example of what i'm working with, working around preexisting code:
I'm trying to figure out how inheritance works in coffeescript. Here's a simplified example
Here's a simplified example of what I'm trying to do: I have 2 controls
Below is simplified example of what I am trying to achieve: class Product(models.Model): #
I'm trying to optimize database queries for a Django app. Here's a simplified example:
Here's a simplified example of an object I have. What I would like to
I look at example of dropdown menu here . Here is simplified jsfiddle example.

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.