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;

using CMS.SettingsProvider;

using CMS.CMSHelper;

using CMS.DataEngine;

using CMS.GlobalHelper;

 

...

 

      // 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 = PollInfoProvider.ACCESS_ALL;

       pollObj.PollOpenFrom = DateTime.Now;

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

 

      // Save the object

      PollInfoProvider.SetPollInfo(pollObj);

 

      // Add poll to current site

      if (CMSContext.CurrentSite != null)

       {

          PollInfoProvider.AddPollToSite(pollObj.PollID, CMSContext.CurrentSite.SiteID);

       }

 

Page url: http://devnet.kentico.com/docs/devguide/index.html?creating_a_new_poll.htm