Cryptic script manager error when using poll in 4.5.2
Hi, just passing on a bit of information about using the poll package under 4.5.2. It looks as if answers to the poll need to be initialised with 0 in the answers property. If you don't do this, submitting the poll will fail with what looks like a javascript error raised by the asp.net ajax script manager, but what is actually a type conversion error. I hope this helps.
Hi Alex, yes, I did, by playing around with the source code - well by "playing" I mean messing about with the source code like a bull in a china shop.
As I remember (no guarantees !) the lines of code causing a problem were those in poll.ascx.cs in methods SelectAwnser() (sic) and RenderResults() which test for properties != DBNull.Value
For example:
if (childDoc.getProperty("votes").Value != DBNull.Value) ...
I replaced those tests with a less efficient one, but which works, which casts the "votes" property value to a string and tests its length. If length > 0 I've cast the string to an integer variable (making the assumption the "votes" value is going to be a number) and then used that variable further on down in the method. Basically what this does is ensure that wherever the methods expect an integer, they are going to get one, even if it's just 0, rather than a null, or zero-length string.
int myvotes = 0;
if (childDoc.getProperty("votes").Value.ToString() != "" )
//insert into table try { if (Membership.GetUser(HttpContext.Current.User.Identity.Name) != null) { int memberid = (int)Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey; int pollid = answerDoc.Parent.Id;
SqlConnection conn = new SqlConnection(umbraco.GlobalSettings.DbDSN); string select = "insert into tblPoll(memberid,pollid,answer) values(@memberid,@pollid,@answer)";
Thanks Tony ! Incidentally, I had come back to making this component work after having tried out Contour for poll functionality. There was nothing wrong with the Contour option, but I appreciate the simplicity/hackability of Tim's Poll user control, and also like the fact the poll questions (and answer statistics) exist as nodes under the poll - which makes it a better "fit" for teaching to my end users.
Cryptic script manager error when using poll in 4.5.2
Hi, just passing on a bit of information about using the poll package under 4.5.2. It looks as if answers to the poll need to be initialised with 0 in the answers property. If you don't do this, submitting the poll will fail with what looks like a javascript error raised by the asp.net ajax script manager, but what is actually a type conversion error. I hope this helps.
Hi Chris
Did you manage to get this to work? I'm trying to adjust the source code to sort this issue out but struggling, do you have any pearls of wisdom?
Thanks,
Alex
Hi Alex, yes, I did, by playing around with the source code - well by "playing" I mean messing about with the source code like a bull in a china shop.
As I remember (no guarantees !) the lines of code causing a problem were those in poll.ascx.cs in methods SelectAwnser() (sic) and RenderResults() which test for properties != DBNull.Value
For example:
if (childDoc.getProperty("votes").Value != DBNull.Value) ...
I replaced those tests with a less efficient one, but which works, which casts the "votes" property value to a string and tests its length. If length > 0 I've cast the string to an integer variable (making the assumption the "votes" value is going to be a number) and then used that variable further on down in the method. Basically what this does is ensure that wherever the methods expect an integer, they are going to get one, even if it's just 0, rather than a null, or zero-length string.
int myvotes = 0;
if (childDoc.getProperty("votes").Value.ToString() != ""
)
{
myvotes = Convert.ToInt32(childDoc.getProperty("votes").Value);
....
If it's going to useful to you I can send the complete modified code - I've also pulled out the (AFAIK) redundant SQL related code.
Cheers !
Chris.
Star!
Thanks Chris! It's all working nicely and saved me my own bull impression!
For anyone else who needs it I'll post the two methods belows.
Cheers,
Alex
Cheers chaps - literally the moment I needed to download this to start using, you guys go and fix a bug before I get started!
Thanks for posting the solution, that probably saved me a couple of hours of aggro! :)
Just expanding on Alex and Chris' excellent work, I've instead opted for parsing the value which also seems to sort out the problem :
Thanks Tony ! Incidentally, I had come back to making this component work after having tried out Contour for poll functionality. There was nothing wrong with the Contour option, but I appreciate the simplicity/hackability of Tim's Poll user control, and also like the fact the poll questions (and answer statistics) exist as nodes under the poll - which makes it a better "fit" for teaching to my end users.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.