Creating a new poll

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The following sample code shows how you can create a new poll using the API:

 

[C#]

 

using CMS.Polls;

 

...

 

        // Create new poll info

        PollInfo pollObj = new PollInfo();

 

        // Set the fields

        pollObj.PollCodeName = "testingSitePoll";

        pollObj.PollDisplayName = "Testing site poll";

        pollObj.PollTitle = "Your free time";

        pollObj.PollQuestion = "What do you do in your free time?";

        pollObj.PollResponseMessage = "Thank you for your vote.";

        pollObj.PollAllowMultipleAnswers = false;

        pollObj.PollAccess = SecurityAccessEnum.AllUsers;

        pollObj.PollOpenFrom = DateTime.Now;

        pollObj.PollOpenTo = DateTime.Now.AddMonths(1);

 

        // Save the object

        PollInfoProvider.SetPollInfo(pollObj);

 

        // Add poll to current site

        PollInfoProvider.AddPollToSite(pollObj.PollID, CMSContext.CurrentSiteID);

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_creating_a_new_poll.htm