Why can't I check a toolbar item on PageLoad

3 posts, 0 answers
  1. Boone
    Boone avatar
    47 posts
    Member since:
    May 2008

    Posted 02 Dec 2009 Link to this post

    protected void Page_Load(object sender, EventArgs e)
            {
                 RadToolBarItem itemToCheck = toolbarNav.FindItemByValue("Trucks");
                  itemToCheck.Checked = false;
            }

    Checked is not there. Why isn't it there? Is there something else I should be using?
  2. Evan Hutnick
    Evan Hutnick avatar
    26 posts
    Member since:
    Sep 2008

    Posted 02 Dec 2009 Link to this post

    Hey Boone,

    Just looked into this and think I have a solution for you.  The first thing to note is that RadToolBarItem is just a generic item, so to speak, which is the base for any of the RadToolBar button types.  Since they all don't support being checked, the base type doesn't support it.

    So, in a case like yours I'm gonna guess you might be using a RadToolBarButton, in which case you'd just do something like this:

            RadToolBarItem rtbi = xRadToolBar.FindItemByValue("Trucks");  
            (rtbi as RadToolBarButton).Checked = true

    That'll give you access to the Checked property and you'll be nearly set.  I say nearly because it appears that the Checked functionality isn't turned on for the individual item unless you have CheckedOnClick="true" in the markup, in which case it'll reflect the Checked style.  Otherwise you can set Checked all day, but the functionality won't be there unless you've told the control in advance that it can be checked (CheckedOnClick="true").

    -Evan
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Boone
    Boone avatar
    47 posts
    Member since:
    May 2008

    Posted 02 Dec 2009 Link to this post

    Perfect, thanks.
Back to Top