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

Forums / Developing with Sitefinity / RadioButtonList Disable ListItems

RadioButtonList Disable ListItems

8 posts, 0 answered
  1. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    18 Aug 2009
    Link to this post

    I am having a strange problem with the RadioButtonList.
    I ported a control from dotnetnuke. To sitefinity.
    A control that is a simple .NET control.

    It has a RadioButtonList, and the items are enabled or disabled depending on what is found in the settings for the control.

    However in sitefinity they are always displayed as enabled. Even when i disable them. Like this:

    radLan.Items[0].Enabled = false;

    radLan.Items[1].Enabled = false;

    radLan.Items[4].Enabled = false;


    What's more i actually run a test putting the value of radLan.Items[4].Enabled.ToString() inside a test text box. And the value appears to be the way i set it. So that seems to work.
    However when i run the page the RadioButtonList appears to ignore that and display the item as not greyed out.

    Is there perhaps some sort of styling in sitefinity that changes the value back client site? Or perhaps another reason why this does not work?


  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    18 Aug 2009
    Link to this post
    Hello Andrew,

    Thank you for using our services.

    Can you provide some more details - sample code (so we can reproduce the problem on our side) or a live example so we can test this problem?
    Did you test your control on standard ASP.NET site?

    Best wishes,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    18 Aug 2009
    Link to this post
    I am afraid the project is not yet on a live site.

    With regards to the code, it's very simple:

    <asp:RadioButtonList ID="radLan" runat="server">   
    <asp:ListItem></asp:ListItem>   
    <asp:ListItem></asp:ListItem>   
    <asp:ListItem></asp:ListItem>   
    <asp:ListItem></asp:ListItem>   
    <asp:ListItem></asp:ListItem>   
    </asp:RadioButtonList>   
     
     
    radLan.Items[0].Enabled = false;   
     


    And yes i did try it in an asp application. It works just fine.
    First item in the list is diabled.

    However when using sitefinity, it is still enabled. I am using 3.7 and IE8

    Thanks
    A
  4. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    19 Aug 2009
    Link to this post
    Hello Andrew,

    I think the problem is caused from the fact that a control is recreated after you have set its properties.
    Can you provide us additional information to reproduce the problem? We cannot reproduce the exact problem locally. If you can send the your control (templates, code behind) it will be great. It is also important to know where you have set the properties ( Page_Load, OnPreRender).

    Sincerely yours,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    19 Aug 2009
    Link to this post
    Here is the whole code: Strangely if i in the same place disable the whole radiolist it does disable it as it should.

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="HISSearch.ascx.cs" Inherits="Cint.HIS.HISSearch" %> 
    <asp:Panel ID="Panel1" runat="server" DefaultButton="cmdSearch">  
        <asp:RadioButtonList ID="radLan" runat="server">  
            <asp:ListItem Selected="True" Value="Botanical">Botanical Name</asp:ListItem> 
            <asp:ListItem Value="Common">Common Name</asp:ListItem> 
            <asp:ListItem Value="Bayer">Bayer Code</asp:ListItem> 
            <asp:ListItem Value="Catalogue">Catalogue Number</asp:ListItem> 
            <asp:ListItem Value="Seed">Seed Mixture</asp:ListItem> 
        </asp:RadioButtonList><asp:TextBox ID="txtSearch" runat="server"></asp:TextBox> 
        <asp:DropDownList ID="lstType" runat="server">  
            <asp:ListItem Value="weeds">Weeds</asp:ListItem> 
            <asp:ListItem Value="herbs">Herbs</asp:ListItem> 
            <asp:ListItem Value="wild">Wildflowers</asp:ListItem> 
            <asp:ListItem Value="pets">Plants for Pets</asp:ListItem> 
        </asp:DropDownList><br /><asp:Button ID="cmdSearch" 
            runat="server" OnClick="cmdSearch_Click" Text="Search" /> 
    </asp:Panel> 
    <asp:Panel ID="Panel2" runat="server">  
    <strong>Browse:</strong><br /> 
    <asp:LinkButton ID="lnkA" runat="server" OnClick="lnkAll_Click">A</asp:LinkButton> 
    <asp:LinkButton ID="lnkB" runat="server" OnClick="lnkAll_Click">B</asp:LinkButton> 
    <asp:LinkButton ID="lnkC" runat="server" OnClick="lnkAll_Click">C</asp:LinkButton> 
    <asp:LinkButton ID="lnkD" runat="server" OnClick="lnkAll_Click">D</asp:LinkButton> 
    <asp:LinkButton ID="lnkE" runat="server" OnClick="lnkAll_Click">E</asp:LinkButton> 
    <asp:LinkButton ID="lnkF" runat="server" OnClick="lnkAll_Click">F</asp:LinkButton> 
    <asp:LinkButton ID="lnkG" runat="server" OnClick="lnkAll_Click">G</asp:LinkButton> 
    <asp:LinkButton ID="lnkH" runat="server" OnClick="lnkAll_Click">H</asp:LinkButton> 
    <asp:LinkButton ID="lnkI" runat="server" OnClick="lnkAll_Click">I</asp:LinkButton> 
    <asp:LinkButton ID="lnkJ" runat="server" OnClick="lnkAll_Click">J</asp:LinkButton> 
    <asp:LinkButton ID="lnkK" runat="server" OnClick="lnkAll_Click">K</asp:LinkButton> 
    <asp:LinkButton ID="lnkL" runat="server" OnClick="lnkAll_Click">L</asp:LinkButton> 
    <asp:LinkButton ID="lnkM" runat="server" OnClick="lnkAll_Click">M</asp:LinkButton> 
    <asp:LinkButton ID="lnkN" runat="server" OnClick="lnkAll_Click">N</asp:LinkButton> 
    <asp:LinkButton ID="lnkO" runat="server" OnClick="lnkAll_Click">O</asp:LinkButton> 
    <asp:LinkButton ID="lnkP" runat="server" OnClick="lnkAll_Click">P</asp:LinkButton> 
    <asp:LinkButton ID="lnkQ" runat="server" OnClick="lnkAll_Click">Q</asp:LinkButton> 
    <asp:LinkButton ID="lnkR" runat="server" OnClick="lnkAll_Click">R</asp:LinkButton> 
    <asp:LinkButton ID="lnkS" runat="server" OnClick="lnkAll_Click">S</asp:LinkButton> 
    <asp:LinkButton ID="lnkT" runat="server" OnClick="lnkAll_Click">T</asp:LinkButton> 
    <asp:LinkButton ID="lnkU" runat="server" OnClick="lnkAll_Click">U</asp:LinkButton> 
    <asp:LinkButton ID="lnkV" runat="server" OnClick="lnkAll_Click">V</asp:LinkButton> 
    <asp:LinkButton ID="lnkW" runat="server" OnClick="lnkAll_Click">W</asp:LinkButton> 
    <asp:LinkButton ID="lnkX" runat="server" OnClick="lnkAll_Click">X</asp:LinkButton> 
    <asp:LinkButton ID="lnkY" runat="server" OnClick="lnkAll_Click">Y</asp:LinkButton> 
    <asp:LinkButton ID="lnkZ" runat="server" OnClick="lnkAll_Click">Z</asp:LinkButton></asp:Panel> 

    using System;  
    using System.Collections;  
    using System.Configuration;  
    using System.Data;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.HtmlControls;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using System.ComponentModel;  
     
    namespace Cint.HIS  
    {  
        [DefaultProperty("Type")]  
        public partial class HISSearch : System.Web.UI.UserControl  
        {
            #region Variables  
     
            private string strPageRedirect = "";  
     
            private string _type = "pets";  
            private string _dataViewPage = "";  
     
            private string _weedsRedirect = "";  
            private string _herbsRedirect = "";  
            private string _wildRedirect = "";  
            private string _petsRedirect = "";  
     
            private bool _botanical = true;  
            private bool _common = true;  
            private bool _buyer = true;  
            private bool _catalogue = true;  
            private bool _seedMix = true;  
     
            private bool _browse = false;  
            private bool _dropDown = false;
            #endregion  
     
            #region Properties  
     
            [Category("HIS Radio Buttons")]  
            public bool BotanicalEnabled  
            {  
                set 
                {  
                    _botanical = value;  
                }  
                get 
                {  
                    return _botanical;  
                }  
            }  
            [Category("HIS Radio Buttons")]  
            public bool CommonEnabled  
            {  
                set 
                {  
                    _common = value;  
                }  
                get 
                {  
                    return _common;  
                }  
            }  
            [Category("HIS Radio Buttons")]  
            public bool BuyerEnabled  
            {  
                set 
                {  
                    _buyer = value;  
                }  
                get 
                {  
                    return _buyer;  
                }  
            }  
            [Category("HIS Radio Buttons")]  
            public bool CataloguelEnabled  
            {  
                set 
                {  
                    _catalogue = value;  
                }  
                get 
                {  
                    return _catalogue;  
                }  
            }  
            [Category("HIS Radio Buttons")]  
            public bool SeedEnabled  
            {  
                set 
                {  
                    _seedMix = value;  
                }  
                get 
                {  
                    return _seedMix;  
                }  
            }  
     
            [Category("HIS Settings")]  
            public string Type  
            {  
                set 
                {  
                    _type = value;  
                }  
                get 
                {  
                    return _type;  
                }  
            }  
            [Category("HIS Settings")]  
            public string DataViewPage  
            {  
                set 
                {  
                    _dataViewPage = value;  
                }  
                get 
                {  
                    return _dataViewPage;  
                }  
            }  
            [Category("HIS Settings")]  
            public bool BrowseVisible  
            {  
                set 
                {  
                    _browse = value;  
                }  
                get 
                {  
                    return _browse;  
                }  
            }  
            [Category("HIS Settings")]  
            public bool DropDownVisible  
            {  
                set 
                {  
                    _dropDown = value;  
                }  
                get 
                {  
                    return _dropDown;  
                }  
            }  
     
            [Category("HIS Redirect")]  
            public string Weeds  
            {  
                set 
                {  
                    _weedsRedirect = value;  
                }  
                get 
                {  
                    return _weedsRedirect;  
                }  
            }  
            [Category("HIS Redirect")]  
            public string Herbs  
            {  
                set 
                {  
                    _herbsRedirect = value;  
                }  
                get 
                {  
                    return _herbsRedirect;  
                }  
            }  
            [Category("HIS Redirect")]  
            public string Wild  
            {  
                set 
                {  
                    _wildRedirect = value;  
                }  
                get 
                {  
                    return _wildRedirect;  
                }  
            }  
            [Category("HIS Redirect")]  
            public string Pets  
            {  
                set 
                {  
                    _petsRedirect = value;  
                }  
                get 
                {  
                    return _petsRedirect;  
                }  
            }
            #endregion  
     
            protected void Page_Load(object sender, EventArgs e)  
            {  
                  
                //For remote seraches, selected from drop down to be send to weeds or herbs etc...  
                try 
                {  
                    switch (lstType.SelectedValue)  
                    {  
                        case "weeds":  
                            strPageRedirect = _weedsRedirect;  
                            break;  
                        case "herbs":  
                            strPageRedirect = _herbsRedirect;  
                            break;  
                        case "wild":  
                            strPageRedirect = _wildRedirect;  
                            break;  
                        case "pets":  
                            strPageRedirect = _petsRedirect;  
                            break;  
                    }  
     
                }  
                catch { }  
     
                radLan.Items[0].Enabled = false;  
                radLan.Items[1].Enabled = false;  
                radLan.Items[2].Enabled = false;  
                radLan.Items[3].Enabled = false;  
                radLan.Items[4].Enabled = false;  
     
                lstType.Visible = _dropDown;  
                Panel2.Visible = _browse;  
            }  
     
            protected void cmdSearch_Click(object sender, EventArgs e)  
            {  
                Session.Add("language", radLan.SelectedValue);  
                Session.Add("searchstring", txtSearch.Text);  
     
                if (lstType.Visible)  
                {  
                    Session.Add("type", lstType.SelectedValue);  
                    Response.Redirect(strPageRedirect);  
                }  
                else 
                {  
                    Session.Add("type", _type);  
                    if (_dataViewPage != "")  
                        Response.Redirect(_dataViewPage, true);  
                }  
            }  
     
            protected void lnkAll_Click(object sender, EventArgs e)  
            {  
                Session.Add("language", radLan.SelectedValue);  
                Session.Add("searchstring", ((LinkButton)sender).Text);  
                  
                if (lstType.Visible)  
                {  
                    Session.Add("type", lstType.SelectedValue);  
                    Response.Redirect(strPageRedirect);  
                }  
                else 
                {  
                    Session.Add("type", _type);  
                    if (_dataViewPage != "")  
                        Response.Redirect(_dataViewPage, true);  
                }  
            }  
     
        }  
  6. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    21 Aug 2009
    Link to this post
    *bump*

    Any news on this?
  7. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    24 Aug 2009
    Link to this post
    Hi Andrew,

    We will continue looking for the reason why the Enabled property do not disable the item.

    Use this workaround until then:
    radLan.Items[0].Attributes.Add("disabled","disabled"); 
    This will make the item disabled.

    I hope this helps you.

    Best wishes,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  8. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    24 Aug 2009
    Link to this post
    This apears to work.
    Thanks, i will do that for now.
Register for webinar
8 posts, 0 answered