You may or may not have noticed the Poll Widget on the left hand side of this blog... This was originally developed by Fatih Sever for BlogEngine.NET 1.x. This widget was so successful that Mads himself didn’t even make one because of Fatih’s hard work.

Since the major release of BlogEngine.NET 2.0, many extensions and widgets (including the Poll Widget) were affected by breaking changes. Because I really needed a Poll Widget ASAP I decided to take the source and update it to work with BlogEngine.NET 2.0 along with a couple of bug fixes to make it more resilient to arbitrary configuration and the new script object.

Fatih has graciously allowed me to host the download on my site as I am continuously making small changes and bugging him all the time for updates is becoming an issue. So here we go:

If you are looking for the Poll Widget that works in BlogEngine 1.x (because this one is not backward compatible) then you can download it from Fatih Sever's original post.

Important Information

Custom Themes
Only the standard theme is updated with the required CSS stylesheet for the Poll Widget. If you are using a custom them you need to follow the steps below:

  1. To add the CSS to the theme that you use open the file .\themes\YourThemeName\site.master and add the following HTML in the HEAD tag along with any other external stylesheet declarations:
    <link rel="stylesheet" href="poll.css" type="text/css" />
  2. Copy the file progress.gif and poll.css from .\themes\Standard\ to your custom theme directory.

Troubleshoot Problems

If the widget won't be added using your current theme you can do two things:

  1. Switch to the Standard theme, add it, then switch back to your theme.
  2.   OR
  3. Edit .\App_Data\datastore\widgets\be_WIDGET_ZONE.xml and add the widget directly with the following XML:
    <widget id="3E9B34D6-2343-11E0-829C-FB02DFD72085"
            title="Poll" showTitle="True">Poll</widget>

    You can change the GUID to any valid GUID value that you want.

    If you get any error with the widget you can usually pick up the script error using developer tools for your browser. IE usually has the script error dialog turned on by default, look for the warning symbol in the bottom left corner.

    If you have the logging extension turned on then non-script widget errors will be logged to .\App_Data\logger.txt by default.

Thanks again to Fatih for the great widget!


Comment by Fatih Sever

I've been want to update the poll widget for BE 2.0 for a long time but I couldn't find the time to do. Thank you so much Werner. I'm redirecting download link to this post, so everyone get updates fast and easily. Thanks again...

Comment by stiri online

Nice post, i`m looking forward for new ones, keep up the great work.

Comment by Custom Software Developer

For those who love polls, this post is a lifesaver and covers all the bases. Thanks for sharing!

Comment by Andrea D&#39;Orio

Beautiful post!! The widget works fine with Standard theme but i cannot make it works on Arthemia Pro 2.0 theme. Can you help me?

Thanks a lot!

Comment by Werner

@[b]Andrea[/b]: I downloaded and tested the Arthemia Pro 2.0 theme and it's pretty easy to get widget in there but in a "non-standard" way.

The theme does not use the usual [i]WidgetContainer.ascx[/i] user control which uses the widgets configured in [i]App_Data\datastore\widgets[/i] which is updated directly from the side panel. The features on the right hand side are hard-coded in [i]site.master[/i] so the simple answer would be to hard code the widget right in there as well.

1. First things first, download the latest Poll Widget control and extract the new stuff in it to your site (I updated the link because there are a couple of extra to make this simpler like a widget zone that just contains the Poll)

2. Follow the Readme.txt section regarding custom themes in the download to get all the required files in the right place and styles sheets in the HEAD tag for the Arthemia Pro 2.0 theme.

3. Just add the following code to [i]site.master[/i] (in the Arthemia Pro 2.0 theme directory) to the area you want the widget to be displayed in:

<div id="sidebar-bottom">
<blog:WidgetZone runat="server" ZoneName="POLL_WIDGET_ZONE" />

The zone only contains the Poll Widget and does not display the title.
I added it to to 'sidebar-bottom' section but you can inject that code in any section you want really. Login as an administrator to edit the polls.
Ideally the theme author should correctly implement the widget section but you can ask him that :)

Comment by Custom Software Development

Thanks for telling us about the Poll Widget. I'm sure lots of people will get use out of it.

Comment by Rustam Abaletdinov

Q about google news requirement to fulfill which i have to get rid of the delimiter | between Name | Description of the post page. How to get rid of this delimiter in blogengine.net 2? i downloaded v2 and run in the vs debugger but cant find the place where it writes the <title> tag into the <header> section so i would have control on the friken delimiter which wont let me satisfy the googlebot-news requirement about natching the post name in the title tag and in the h1 tag. Thanks a lot! rus [email protected]

Comment by Rustam Abaletdinov

...just wanted to thanks much Werner for immediate answer to solve (my own problem as i need to get new eyeglasses to see obvious check-marks on the blogengine.net v2 admin page:) now we are complete and good for Google News requirements at gps4us.com/news/ thanks again!

Comment by hp veer cases

So very awesome. I really needed a poll module.

Comment by Mark

Works like a charm, thanks.

Comment by fabric blinds

Since the major release of BlogEngine.NET 2.0, i have had some bugs with my blog poll widget but after the 2.5 installation everything seems to work now thanks for the infomation.

Comment by Eventige.com

I agree... we do lots of posting and often polls are a good way to find out about what followers think about your content

Comment by Pest Control

I've beel looking for a decent Poll widget. Thanks.

Pest Control
Comment by Andrea D&#39;Orio

Thanks a lot Werner and sorry for the long await response. All works good with BE 2.0 with XML data provider. Now i'm trying to upgrade my blog to BE 2.5 with SQL CE 4.0... but in the setup folder i cannot find the .sql file for this type of db server. Can you help me?

Andrea D&#39;Orio
Comment by Werner

[b]@Andrea:[/b] I simply updated the poll widget from Fatih's original version to work on BE 2.x, I never updated it to support all the different databases out there.
I made some minor updates to make it work on 2.5 (link above) but I'm still using the XML data provider. It shouldn't be hard to take the existing SQL Server scripts and port them to CE, in fact they may just work out the box.
Since CE is implemented as just another DB provider the Poll widget should still work as expected.

Comment by เก้าอี้แขนอ่อน

Oh my goodness! an amazing article dude. Thank you However I am experiencing issue with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting identical rss problem? Anyone who knows kindly respond. Thnkx

Comment by Ivan

Have installed it on BE v.2.5, but I have a problem it does not track votes. After selecting answer, click vote and results don't show, click on show results and all answers are 0%. Tried many times it's not working for me :(

Comment by Werner

[b]@Ivan:[/b] After clicking an answer it will not immediately show the effect because it submits it via script and the answers are cached to avoid a reload. You can only answer once per poll as a user to prevent abuse, so try another browser as you may also be having script issues. If you have any further problems please contact Fatih Sever, he is the original developer on this, I just updated it slightly to support newer versions of BlogEngine cause I needed it when I started using 2.0 :)

Comment by Werner

The RSS feed has been fixed. It was an issue with the upgrade to AddThisV5. The code is trying to add share/bookmark buttons to the feed when certain information was not available without proper checks, I'll have to tell them sometime...

Comment by Betty

I used the poll widget on my blog and it worked well. I found out some good information about my readers and was better able to target my marketing to them as result. Thanks.


Comment by George

Ditto! No Luck with BE 2.5 with MSSQL Database. Any help appreciated....


Comment by Werner

Successfully tested the Poll Widget in BE 2.5 using the MySQL provider. I followed these steps:

[b]1.[/b] Created a database and installed the objects with [i]\setup\MySQL\MySQLSetup2.5.0.sql[/i] that comes with BlogEngine.

[b]2.[/b] Installed the Poll Widget database objects using [i]\setup\MySql.sql[/i] in the Poll Widget archive.

[b]3.[/b] Downloaded the latest MySQL .NET Connector v6.4.3 from dev.mysql.com/downloads/connector/net/#downloads choosing the .NET & Mono version.

[b]4.[/b] Copy the binary files for the specific version of the connector ([i]mysql.data.dll[/i] etc) to the [i]Bin[/i] directory of BlogEngine.

[b]5.[/b] Update my connection string in [i]web.config[/i]:
[i]<add name="BlogEngine" connectionString="Server=localhost;Database=blogengine;Uid=root;Pwd=secretstuff" providerName="MySql.Data.MySqlClient"/>[/i]

[b]6.[/b] Added the connector assembly and version to [i]web.config[/i]:
<clear />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,
Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
(check the example config files in [i]\setup\MySQL[/i])

Everything worked after all that. I logged in as an admin, added the Poll and created some entries, no problems.

Comment by George

MySQL is fine.

The problem is with MS SQL server.

When you install and try to add a poll you simply get a a message stating that there is a database error and please check the database.

The DB is fine.

The poll works fine in all other setups. MySQL, XML etc.

My blog is set to the SQL provider so my options are restricted to MS SQL.

This is a great widget so I really want to crack this. Any suggestions are very welcome.

Comment by Werner

Noooooo! Shows you what happens when I read too quickly, oh well, I guess I benefited from getting this working with MySQL anyway.

I haven't had an issue like this with SQL Server, the only thing I can think about is a strange issue that used to happen when the [b]providerName="System.Data.SqlClient"[/b] attribute was missing from connection string tag.

Full error details should also be logged in detail to [i]\App_Data\logger.txt[/i] unless you are using a different logger. The stack trace here will help identify what the real issue is. Remember that I didn't write this code, I just updated it to work on newer version of BlogEngine, so you have to be specific about the error message.

Comment by John-Henry

Werner jou Yster!!! Dankie vir die poll box!

Comment by gobbyteacher.com

Rock and roll!
yep, got the poll to work (though strangely I had to install via the standard template AND create an initial poll before it would appear on my blog template), but it does what it sez on the tin. Excellent work.
What I now need are multiple polls, i.e. I want to be able to add a poll in each post. I noticed Fatih had mentioned he was working on a poll control - any progress on this? Then we're going to be cooking!

Comment by markm75

For some reason when I use this.. if you vote for the first time, it says your vote has been registered.. but doesnt show the bar graphs (progress bars).. you have to refresh the page for that to work..

Any thoughts?

Comment by Werner

[b]@markm75:[/b] I am aware of this issue. It's just because the script makes the poll visible before the data is actually captured and updated on the server. There should probably be a callback that updates the statistics once a vote is made, I'll see if I can update it on Fatih's behalf and upload a new version.

Comment by James

I have the poll showing on the page but it says no poll. As I look through the code it looks like it uses polls.xml file to set up the poll? Is there an example of how to use this xml file to populate the poll question?

Thank you.

Private reply: You can set the polls when logged in as an admin directly from the widget the same way you would normally configure widget settings.

Comment by Jim Bean

Nice widgy, dude. Up and working in my ver 2.5 site. Thank you.


Jim Bean
Comment by William Ruto

After the RSS feed issue was fixed, i've used it in one of my widgets and everyone seems to be happy. I'm happy, my readers are happy and one more thing to add to the quality of my blog.


William Ruto
Comment by private cloud

i concur that the problem lies with MS SQL server. relevant info though!

private cloud
Comment by Champagner kaufen

thanks a lot for this code.

Champagner kaufen
Comment by champagner kaufen

the poll widget is very helpful. thank you for sharing

champagner kaufen
Comment by gobbyteacher

ok, have now written a voting widget based on BrutalDev/Fatih's work that dishes up individual polls per blog, as per gobbyteacher.com (click on an individual post and the poll appears top-right) However it took a bit of tinkering with Mayank Raichura's code to do it, but it works. If there's any interest I can write up the code?

Post comment