Introduction

Microsoft WebMatrix provides an easy way to get started with web development, and together with new Razor syntax for ASP.NET Web Pages it includes everything you need to get your web site up, running and integrated with many other sites and networks, in a short period of time. The WebMatrix helpers are designed to make your life easier when creating web sites. They provide you a simple and consistent way of performing common web development tasks that otherwise would require a great deal of custom coding. With a few lines of code you should be able to secure your web site using membership, store information in Windows Azure Storage, integrate your site with Facebook, among others things.

The Polldaddy helper makes it easy to add Poll widgets, ratings and surveys to your WebMatrix site in a few lines of code. It also provides access to the Polldaddy API, wrapping some of the API methods to retrieve Poll data.

polldaddy-helper

Depending on the helper feature you want to use, the helper requires that you call an initialization method. See the Helper Reference to check each case. For using helper methods without initialization see the Getting Started in 60 seconds (without initialization) section, otherwise see the Getting Started in 60 seconds (with initialization) section.

Getting Started in 60 Seconds (without Initialization)

To use the helper to display a Poll Widget, follow these steps:

  1. If you haven't got a Polldaddy account, signup for a free account.
  2. Select the Polls option from the Polldaddy Home page, and create a new Poll (also, post some votes to the Poll).
  3. Download the helper package and extract its content in the root folder of your WebMatrix site.
  4. In any WebMatrix page, add the following line to display your Poll (replace the placeholder with the Id of your Poll):
    @Polldaddy.GetPollWidget("{your-poll-id}")
    

Getting Started in 60 Seconds (with Initialization)

These steps will guide you on how to display the Poll results of a given Poll in your site:

  1. Click here to register for the Polldaddy API. Make note of the Polldaddy API key.
  2. If you haven't created a Poll yet, select the Polls option from the Polldaddy Home page, and create a new Poll (also, post some votes to the Poll).
  3. Download the helper package and extract its content in the root folder of your WebMatrix site.
  4. Add the following line to the _AppStart.cshtml page of your WebMatrix site (if the file does not already exist, create it in the root of the website). Replace the placeholder with your Polldaddy API key.
    @{
        Polldaddy.Initialize("{your-api-key}");    
    }
  5. In any WebMatrix page, add the following code to display the results of your Poll (replace the placeholder with the Id of your Poll):
    @{
        var results = Polldaddy.GetPollResults("{your-poll-id}");
        var grid = new WebGrid(results);
    }
    ...
    @grid.GetHtml()
    

Documentation and Samples

Helper reference is available here. Optionally, you can download a sample WebMatrix web site based on the Bakery template, where you can see the helper in action. To download and run it with Microsoft WebMatrix, follow these steps:

  1. Download the sample site from the Downloads section. Extract the contents and open the folder in WebMatrix.
  2. Run the web site!

Other Useful Resources

Don't miss the helper's getting started screencast.

You can find more information about the Polldaddy API in http://support.polldaddy.com/api/.

Learn more on WebMatrix, ASP.NET Web Pages and the Razor Syntax with the WebMatrix tutorials.

Last edited Dec 28, 2010 at 4:36 PM by jsenior, version 11