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

Forums / Designing with Sitefinity / Global Theme somewhere?

Global Theme somewhere?

22 posts, 0 answered
  1. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    21 Oct 2008
    Link to this post
    I have code and themes that i am migrating into SiteFinity... Specifically i have a RadioButtonList. For some reason, because it is in SiteFinity now, the RadioButtonList is generating this in the source of the page:
    <ul class="forms_locations"
         <li><input id="controlidd" type="radio" name="controlname" value="1253" /> 
             <label for="lableid">Psuedo</label> 
         </li> 
    </ul> 
     

    My original page source looks like this:

    <table class="Forms_Locations" border="0" style="font-weight:bold;width:414px;"
        <tr> 
            <td><input id="controlid" type="radio" name="controlname" value="1253" /> 
                <label for="labelid">Pseudo</label> 
            </td> 
        </tr> 
    </table> 
     

    Although i have never had to set this before i have now set the RepeatLayout of the RadiobuttonList, but get no change...

    Here is the implementation of the control:

    <asp:RadioButtonList ID="Locations" CssClass="forms_locations" runat="server" Width="414" ValidationGroup="ValView1" RepeatColumns="3" DataValueField="SITE_LOCATION_ID" Font-Bold="true" DataTextField="SITE_LOCATION_NAME" RepeatLayout="Table"></asp:RadioButtonList> 


    Nothing has changed in my styles, no code has changed in how this list is displayed on the page.

    Is there something that might be effecting this control? Some global theme or something?

    Nugs
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    21 Oct 2008
    Link to this post
    this is happening because of a control adapter that is overriding the rendering of the control. this is used to control the markup rendered by specific controls and is defined in the App_Browsers folder.

    if you would like to disable this control adapter (and render the old way) open the BrowserFile.browser and remove this line

    <adapter controlType="System.Web.UI.WebControls.RadioButtonList" adapterType="Telerik.Cms.Web.UI.Adapters.RadioButtonListAdapter" /> 

    although keep in mind that if you do this, the radiobuttonlist will render the standard asp.net way, meaning some of the admin stuff that depends on the new rendering may be broken. shouldn't affect functionality tho, just your css might need some adjustment

    hope this was helpful!
  3. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    21 Oct 2008
    Link to this post
    SelArom,

    Is there a way to override this in the code behind so that i do not have to mess up any SiteFinity rendering? Or is there some way where the adapter is flexable enough to give me best of both worlds?

    Nugs
  4. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    21 Oct 2008
    Link to this post
    I don't know of any way to "split" the control adapter so that it can render in multiple formats...
     
    owever what you could do is make your own custom radiobuttonlist control, inheriting from radiobuttonlist, and use that in your website. that way only the original, built-in radiobuttonlistcontrol will be rendered with the control adapter, and the one you make, which will be exactly the same as the original except have a different name, will bypass the adapter and render as normal.
  5. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    21 Oct 2008
    Link to this post
    How about the control itself, are there any properties that will allow me to display the ButtonList in different ways maybe?
  6. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    21 Oct 2008
    Link to this post
    i don't believe so, because controladapters use the control type (that is the class itself) to determine whether or not to override rendering. whatever you might set to the control, it will still be a radiobuttonlist so the control adapter will kick in and render it with the alternative markup
  7. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    21 Oct 2008
    Link to this post
    I think as an alternative you could write your own controladapter that would change rendering based on some built-in property of the radiobuttonlist, but this might be more difficult than just making a copy of the radiobuttonlist and using that instead

  8. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    21 Oct 2008
    Link to this post
    I do have to say that is rather annoying... May i ask why SiteFinity did not create a copy of the RadioButtonList to override itself? That way the front end of the site can still use all standard .Net controls without the rending being hijacked...

    Also would it be to much trouble to provide me with some quick code that i can use to copy the RadioButtonList into a custom control as you have suggested?

    Nugs
  9. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    21 Oct 2008
    Link to this post
    no problem at all except that I've never done it before. thanks for helping me learn something new :)

    okay like I said basically all you have to do is inherit the base class of radiobuttonlist. Put this in your App_Code folder you can call it MyRadioButtonList.cs:

    using System;  
    using System.Collections.Generic;  
    using System.Web;  
    using System.Web.UI.WebControls;  
     
    namespace System.Web.UI.WebControls  
    {  
        /// <summary>  
        /// Summary description for MyRadioButtonList  
        /// </summary>  
        public class MyRadioButtonList : RadioButtonList  
        {  
     
        }  

    then register this control in your web.config so that you can use it in all your custom pages:

    <system.web> 
        <pages> 
            <controls> 
                <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="App_Code" /> 
            </controls> 
        </pages> 
    </system.web> 

    finally just type in the control as if it were a regular asp.net control:

    <asp:MyRadioButtonList ID="RadioList" runat="server"></asp:MyRadioButtonList> 

    and set all the properties as you would with any regular radiobuttonlist!

    I believe you can also register this control into the sitefinity toolbox if you needed to.

    I hope this was helpful!
  10. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    21 Oct 2008
    Link to this post
    Always happy to help ;)

    Thanks this looks pretty straight forward... Appreciate you help...

    One last question though. I notice you have an adapter for System.Web.UI.WebControls.HyperLink Anything i need to be concerned about here in terms of the rendering?

    Nugs
  11. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    21 Oct 2008
    Link to this post
    I haven't encountered any issues with changes in rendering for the hyperlink nor the htmlform, so you're probably in the clear. but if you encounter an issue you'll know what to do :)
  12. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    21 Oct 2008
    Link to this post
    lol, for sure! Getting rather good at this forum thing...

    Nugs
  13. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    21 Oct 2008
    Link to this post
    SelArom,

    I created a custom control that inherits RadioButtonList...

    using System; 
    using System.Collections.Generic; 
    using System.Text; 
    using System.Web; 
    using System.Web.UI.WebControls; 
     
    namespace RadioButtonListOverride 
        public class RadioButtonListOverride : System.Web.UI.WebControls.RadioButtonList 
        { 
     
        } 

    <%@ Register Assembly="RadioButtonListOverride" Namespace="RadioButtonListOverride" TagPrefix="cc1" %> 
     
    ... 
     
    <cc1:radiobuttonlistoverride id="Locations" skinid="RdoLocation" runat="server" width="414" validationgroup="ValView1" repeatcolumns="3" datavaluefield="SITE_LOCATION_ID" font-bold="true" datatextfield="SITE_LOCATION_NAME" /> 


    Unfortunatley this STILL renders with the adapter rendering... :(((

    Am i doing something wrong here?

    Nugs
  14. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    21 Oct 2008
    Link to this post
    namespace System.Web.UI.WebControls 
        public class RadioButtonListOverride : RadioButtonList 
        { 
     
        } 
    Same result...

    What exactly is the implications of removing the adapter for this control? What will is effect?

    Nugs
  15. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    22 Oct 2008
    Link to this post
    hmm darn i'm sorry if i led you on the wrong path I was certain this would work!

    removing the control adapter shouldn't break anything, the only thing it will do is cause the html to be rendered using the built in asp.net renderer, which is the table, which is what you want. but this means that ALL radiobuttonlists will render this way, including the ones in sitefinity admin. if any. i'm not sure where or if there are any but I would assume that there is since they took the time to override the control adapter.

    try deleting the line from the .browsers file and see if it affects anything. like i said it will not break anything, the worst that will happen is you will have to mess with the css to make it fit your template.
  16. Pepi
    Pepi avatar
    981 posts
    Registered:
    08 Dec 2016
    22 Oct 2008
    Link to this post
    Hello,

    Actually, removing the adapter will break a great part of Sitefinity built-in functionality (for example, the control designer of the Lists control). If you want to use the standard ASP.NET functionality, follow the instructions below:

    1. Create a class in ~/App_Code that inherits RadioButtonList:

    using System; 
    using System.Data; 
    using System.Configuration; 
    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; 
     
    /// <summary> 
    /// Summary description for CustomRadioButtonList 
    /// </summary> 
    namespace System.Web.UI.WebControls 
        public class CustomRadioButtonList : RadioButtonList 
        { 
        } 

    2. Add the following row in controlAdapters section of ~/App_Browsers/BrowserFile.browser file (this is the step that Josh has missed):

    <adapter controlType="System.Web.UI.WebControls.CustomRadioButtonList" adapterType="" /> 

    3. Use
    in your code CustomRadioButtonList control instead of the ASP.NET RadioButtonList:

    <%@ Register Assembly="App_Code" Namespace="System.Web.UI.WebControls" TagPrefix="asp" %> 
    ... 
        <form id="form1" runat="server"
    ... 
                    <asp:CustomRadioButtonList ID="CustomRadioButtonList1" runat="server"
                        <asp:ListItem Text="ListItem 1" Value="0"></asp:ListItem> 
                        <asp:ListItem Text="ListItem 2" Value="1"></asp:ListItem> 
                    </asp:CustomRadioButtonList> 
    ... 

    For details please refer to the following KB article: Rendering RadioButtonList.

    Hope you will find the provided information helpful.

    Regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  17. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    22 Oct 2008
    Link to this post
    lol darn i knew i was close. little did I know there was a kb article and everything!
  18. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    22 Oct 2008
    Link to this post
    Thanks Pepi,

    That did the trick! You were very close SelArom. Thank you for all your input...

    Duncan
  19. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    26 Jan 2009
    Link to this post
    Morning everyone,

    I am revisiting this post after some time as i have run into a snag with the solution that was provided to me... I have had questions on this posted on other forums for some time now with not very much response to the problem.

    Since i am forced to override the RadioButtonList because it is being rendered exclusively for SiteFinity admin... I thought i would request SiteFinity's help in resolving the issues i am having with overriding the standard RadioButtonList control.

    My issue is that i now have the need to list off items within the control and do not have access to <asp:ListItem as i would with a standard RadioButtonList:

    <asp:RadioButtonList ID="rdoTest" runat="server">
       <asp:ListItem Text="1" Value="1" Selected="True"></asp:List
    Item>
       <asp:ListItem Text="2" Value="2" Selected="false"></asp:Lis
    tItem>
    </asp:RadioButtonList>


    Question is how can i modify the solution provided to me in this post to make the override class work exactly like a standard <asp:RadioButtonList control, <asp:ListItem's and all!

    Duncan


  20. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    27 Jan 2009
    Link to this post
    Hello Duncan,

    Thank you for contacting us.

    You should be able to work with ListItems without problems.
    Can you give us a concrete example, because we cannot reproduce the problem?
    Sample code will be very helpful to understand the issue.

    We tested this example and it worked:
    <asp:CustomRadioButtonList ID="CustomRadioButtonList1" runat="server">    
        <asp:ListItem Text="1" Value="1" Selected="True"></asp:ListItem> 
        <asp:ListItem Text="2" Value="2" Selected="false"></asp:ListItem> 
    </asp:CustomRadioButtonList>   

    You can work with list items in the code behind too:
        protected void Page_Load(object sender, EventArgs e)  
        {  
            CustomRadioButtonList1.Items.Clear();  
            CustomRadioButtonList1.Items.Add(new ListItem("1""1"));  
            CustomRadioButtonList1.Items.Add(new ListItem("2""2"));  
            CustomRadioButtonList1.Items.Add(new ListItem("3""3"));  
        } 

    Hope this information will help you.

    Greetings,
    Parvan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  21. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    27 Jan 2009
    Link to this post
    Ok i have a Custom Control which inherits RadioButtonList as the solution suggested:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;

    namespace System.Web.UI.WebControls
    {
        [Themeable(true)]
        public class RadioButtonListOverride : System.Web.UI.WebControls.RadioButtonList
        {

        }
    }

    I then add this Custom Control as a refference to my project and use it on my User Control like this:

    <%@ Register Assembly="RadioButtonListOverride" Namespace="System.Web.UI.WebControls"
        TagPrefix="cc1" %>
    ...
    <cc1:RadioButtonListOverride ID="rdoSelectSearchType" SkinID="sknRBLOverride_SearchType"
                        runat="server" />

    The above example wourks find and yes i can add item to the list via the code behind but when i attempt to do this:

    <cc1:RadioButtonListOverride ID="rdoSelectSearchType" SkinID="sknRBLOverride_SearchType" runat="server">
        <asp:ListItem Text="1" Value="1" Selected="True"></asp:ListItem>
    </cc1:RadioButtonListOverride>

    Intelisense throws the following error:

    Element 'ListItem' is not a known element. This can occur if there is a compilation error in the Web site.

    Thanks,

    Duncan
  22. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    27 Jan 2009
    Link to this post
    oh my god, i just answered my own question...

    Apparently the cc1 tag prefix was causing the issue... Changing my control reference to this:

    <%@ Register Assembly="RadioButtonListOverride" Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>

    Solves my problem...!

    Sorry for wasting your time!

    Duncan
Register for webinar
22 posts, 0 answered