More in this section

Forums / Developing with Sitefinity / A way to override PollBox.CheckVisitorStatus

A way to override PollBox.CheckVisitorStatus

4 posts, 0 answered
  1. Victor
    Victor avatar
    44 posts
    Registered:
    10 Mar 2009
    17 Aug 2009
    Link to this post
    Hello,

    I was looking into customizing PollBox to allow a logged in user to answer a poll only once. I see there is a CheckVisitorStatus method I could override to check a lookup table instead of Ip address but it is private. Any chance to make this method virtual in a future patch?

    Thanks,
    Victor
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Aug 2009
    Link to this post
    Hi Victor,

    Thank you for using our services.

    CheckVisitorStatus is used to get user's IP address and check whether a user has already been voted. The method uses ipBlocking property which is publicly exposed and you can use it programmatically or through PollBox's ControlDesigner properties. By default ipBlocking is set to true which means that an user can vote only one time until you release the IP address.

    Just to let you know all modules from Sitefinity 4.0 will be Generic Content based and we will try to make more methods public so that users can access and override them.

    Kind regards,
    Ivan Dimitrov
    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.
  3. Victor
    Victor avatar
    44 posts
    Registered:
    10 Mar 2009
    20 Aug 2009
    Link to this post
    Thanks for the reply,

    Unfortunately for our customer "wait for next version" doesn't play very well.

    It seems I would have to override button_click but reflector shows a lot of code I would have to copy over. I also see no other hooks I can override... any suggestions?

  4. Victor
    Victor avatar
    44 posts
    Registered:
    10 Mar 2009
    24 Aug 2009
    Link to this post
    FYI we managed a solution by deriving pollbox into our own server control and hooking an extra event handler to button_click. I'm posting this as a reference if anybody else comes up with a similar issue:

        public class MyPollBox : PollBox 
        { 
            public long UserId { getset; } 
     
            public override Type LocalizationAssemblyInfo 
            { 
                get 
                { 
                    return typeof(PollBox); 
                } 
                set 
                { 
                    base.LocalizationAssemblyInfo = value; 
                } 
            } 
            public override Type AssemblyInfo 
            { 
                get 
                { 
                    return typeof(PollBox); 
                } 
                set 
                { 
                    base.AssemblyInfo = value; 
                } 
            } 
     
            protected override void InitializeControls(System.Web.UI.Control controlContainer) 
            { 
                //call base class  
                base.InitializeControls(controlContainer); 
     
                // hook our own handler 
                this.VoteButton.Click += new EventHandler(SaveVote); 
     
            } 
     
     
            protected void SaveVote(object sender, EventArgs e) 
            { 
                if (UserId == -1) 
                    throw new InvalidOperationException("Must login to vote"); 
     
                SurveyVotes.Add(UserId, this.PollId); 
            } 
     
     
        } 

Register for webinar
4 posts, 0 answered