BlogEngine.NET 2.x Poll Widget
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:
- 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" /> - Copy the file progress.gif and poll.css from .\themes\Standard</em> to your custom theme directory.
Troubleshoot Problems
If the widget won't be added using your current theme you can do two things:
Switch to the Standard theme, add it, then switch back to your theme.
OR
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!

The conversation
37 commentsThanks a lot!
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">
<h3>Poll</h3>
<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 :)
Sincerely,
Rus
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.
http://www.michebagshells.com/
http://www.developerstalk.com
http://2gassociates.co.uk
[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 http://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]:
[i]<system.data>
<DbProviderFactories>
<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=6.4.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>[/i]
(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.
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.
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.
http://www.xosoftware.co.uk
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!
Any thoughts?
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.
JimInDurbz
http://capbn.com