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

Forums / Developing with Sitefinity / Poll custom look

Poll custom look

6 posts, 0 answered
  1. Pedro De Sousa
    Pedro De Sousa avatar
    4 posts
    Registered:
    24 Nov 2009
    01 Feb 2010
    Link to this post

    Hi,

    Is it possible to have the look of the following poll sample ( http://img18.yfrog.com/img18/5203/custompollsample.jpg ) with the sitefinity poll module ?

    The point is I need percentage values of every answer and not absolute values. Can you explain briefly how to get there without rewriting a custom poll module ?

     

    Thank you in advance.

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    01 Feb 2010
    Link to this post
    Hi Pedro De Sousa,

    Thank you for using our services.

    Unfortunately this cannot be achieved without creating custom controls for the Polls module. The polls module uses a control which draws charts and generates images for them. So actually the absolute value which you see can only be removed if you create a custom results box control. For example you can create a control inheriting from the original one and override the CreateRadChart method and set the label holding the values to an empty one. Sample code is bellow:

    using System;
    using System.Drawing;
    using Telerik.Charting;
    using Telerik.Charting.Styles;
    using Telerik.Polls.WebControls;
    using Telerik.Web.UI;
     
    /// <summary>
    /// Summary description for CutomResultBox
    /// </summary>
    public class CutomResultsBox: ResultsBox
    {
        public override string LayoutTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/Polls/ResultsBoxNoLegend.ascx";
            }
            set
            {
                base.LayoutTemplatePath = value;
            }
        }
        protected override RadChart CreateRadChart()
        {
            RadChart chart = new RadChart();
            chart.ID = "answerChart";
            chart.EnableViewState = false;
            chart.Legend.Visible = false;
            chart.ChartTitle.Visible = false;
            chart.SeriesOrientation = ChartSeriesOrientation.Horizontal;
            chart.Width = this.BarsWidth;
            chart.Height = this.BarsHeight;
            chart.UseSession = false;
            chart.TempImagesFolder = "~/App_Data/Polls_Temp";
            chart.Appearance.Border.Visible = false;
            chart.Appearance.Border.Color = Color.Transparent;
            chart.Appearance.BarWidthPercent = 100M;
            chart.Appearance.FillStyle.MainColor = Color.AliceBlue;
            chart.PlotArea.Appearance.Dimensions.Margins.Bottom = Telerik.Charting.Styles.Unit.Pixel(0f);
            chart.PlotArea.Appearance.Dimensions.Margins.Top = Telerik.Charting.Styles.Unit.Pixel(0f);
            chart.PlotArea.Appearance.Dimensions.Margins.Right = Telerik.Charting.Styles.Unit.Pixel(0f);
            chart.PlotArea.Appearance.Dimensions.Margins.Left = Telerik.Charting.Styles.Unit.Pixel(0f);
            chart.PlotArea.XAxis.Visible = ChartAxisVisibility.False;
            chart.PlotArea.Appearance.Border.Visible = false;
            chart.PlotArea.Appearance.FillStyle.FillType = FillType.Solid;
            chart.PlotArea.Appearance.FillStyle.MainColor = Color.Transparent;
            chart.Series.Add(new ChartSeries());
            chart.Series[0].Items.Add(new ChartSeriesItem());
            chart.Series[0].DefaultLabelValue = "";
            return chart;
        }
    }



    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    29 Jan 2011
    Link to this post
    How can I get Poll results and Bind this to our Custom control?
  4. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    29 Jan 2011
    Link to this post
    How can I set Tell Sitefinity Pollbox to use my Custom class?

    By default it uses its predefined classes and Templates.I tried to set it not able.

    I have found a property "Template Path" but it was obsolete .

    Can you please give me guide lines, what property can be used to override default one with My CustomResultsBox .
    And How can I get and Bind Poll answers to My CustomResultsBox.

    Thanks
    Venkat
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    31 Jan 2011
    Link to this post
    Hello Venkat,

    You need to define your custom result box inside a custom PollBox

    public class CustomPollsBoxToolBoxItem : ToolboxItem
      
    {
      
        publicCustomPollsBoxToolBoxItem()
      
            : base(typeof(CustomPollsBox))
      
        {
      
            this.DisplayName = "CustomPollsBox";
      
            this.Description = "CustomPollsBox Desc";
      
        }
      
    }
      
     
      
    [System.ComponentModel.ToolboxItem(typeof(CustomPollsBoxToolBoxItem))]
    class CustomPollsBox : PollBox
    {
        public CustomPollsBox()
        {
            this.ResultsBox = newCustomResultsBox();
      
            this.ResultsBox.LayoutTemplate = ControlUtils.GetTemplate("~/Sitefinity/ControlTemplates/Polls/ResultsBoxNoLegend.ascx", string.Empty, null)
      
        }
      
        
      
        
      
    ....
      
       ....
      
    }
      
       
      
    public class CustomResultsBox : Telerik.Polls.WebControls.ResultsBox
     
    {
        public CustomResultsBox()
        {
      
      
        }
      
        
        protectedoverrideTelerik.Web.UI.RadChart CreateRadChart()
        {
            // GENERATE NEW RAD CHART HERE
        }


    Greetings,
    Ivan Dimitrov
    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
  6. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    23 Mar 2011
    Link to this post
    I have created a custom poll box to display poll results  with out images.We can customize its width, Bar Color and Main Color on the admin side. It uses cookie to block the user from voting again.

    Here is the  full description of the this Custom poll Box in the below link.

    http://vangalvenkat.blogspot.com/2011/03/sitefinity-custom-pollbox.html

    Thanks
    Venkat
Register for webinar
6 posts, 0 answered