1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Disabling Radio Buttons in RadioButtonList

Disabling Radio Buttons in RadioButtonList

6 posts, 0 answered
  1. Jon Kramme
    Jon Kramme avatar
    15 posts
    Registered:
    20 Dec 2009
    26 May 2010
    Link to this post
    I'm running into a problem with the control adapter used by Sitefinity 3.7 for RadioButtonLists...

    I have a single RadioButtonList control with 4 ListItems within it.  At run time, based on a condition in my database, I may need to disable one or more of those ListItems.

    When the control adapter is remarked out in BrowserFile.browser, it works fine.  But, when the adapter is live, I cannot disable individual items in the RadioButtonList. 

    I don't want to disable the control adapter across the entire site, since that will have negative side-effects elsewhere, but unless there is another solution, I'll have to.

    My code looks something like below...

    foreach (EventsDataSet.EventSessionsRow session in sessions)
    {
        ListItem item = rblSessions.Items.FindByValue(session.ses);
        if (item != null)
        {
            if (session.soldout)
            {
                //This line works without the control adapter, but not with it...
                item.Enabled = false;
            }
        }
    }

    Thanks!
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 May 2010
    Link to this post
    Hi Jon Kramme,

    Thank you for using our services.

    Could you please take a look at the following KB article: RadioButtonList rendered as <ul> . The article discusses how to change the appearance of the RadioButtonList using styles. In your case for the buttons that you do not wish to show you can use display: none style, something like the sample bellow:
    foreach (EventsDataSet.EventSessionsRow session in sessions)
    {
        ListItem item = rblSessions.Items.FindByValue(session.ses);
        if (item != null)
        {
            if (session.soldout)
            {
               item.Attributes.Add("style", "display: none;");
            }
        }
    }


    Greetings,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Jon Kramme
    Jon Kramme avatar
    15 posts
    Registered:
    20 Dec 2009
    26 May 2010
    Link to this post
    Hello Radoslav,

    Thank you for the quick reply.  I did successfully try that yesterday as an experiment, but our customer's requirement is to disable the radio button, not hide it.  I tried variations on that, like item.Attributes.Add("style", "disabled: true;"), but it didn't work because the style was applied to the containing <li> tag instead of the <input> tag.  Is there a similar technique to disable the input inside the li?

    Thanks!
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 May 2010
    Link to this post
    Hi Jon Kramme,

    The problem is that you cannot control behavior using CSS (disabled/enabled), only appearance. What you can do is to add an attribute to the <li> element. Then on document.ready with jQuery to get all <li> elements with this attribute set and get the <input> element inside the <li> and disable it.
     
    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Jon Kramme
    Jon Kramme avatar
    15 posts
    Registered:
    20 Dec 2009
    26 May 2010
    Link to this post
    Thanks again for the quick reply.  Please accept the following constructive criticism of the radio button list control adapter to be considered for a future release...

    The adapter should not remove functionality provided by the core Microsoft control that it extends.  It's fine to create a better rendering solution, since the Microsoft controls are notoriously heavy in their HTML markup.  However, in achieving that goal, features that the original control provided, such as Enabled, RepeatDirection, RepeatColumns, etc., should not be disabled.

    As it stands now, I'm faced with selecting from the jQuery workaround you described (extra time/cost), hiding instead of disabling (not what the customer wants), leave the feature out (also not what the customer wants), or disabling the adapter (big ramifications for the Sitefinity CMS admin pages).

    In general, I think Sitefinity is a great product, as are the RAD controls.  But I think the implementation of this control adapter was done poorly and hope to see it fixed in a future release.
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 May 2010
    Link to this post
    Hi Jon Kramme,

    Thank you for the feedback. We appreciate that you are sharing your thoughts on this. Indeed this control adapter is not implemented very well - it is adding unnecessary complexity to using a regular ASP.NET control. I will address your concerns to the team and make sure that we improve this for our future releases.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
6 posts, 0 answered