+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Null reference exception in Poll

Null reference exception in Poll

3 posts, 0 answered
  1. Nitin
    Nitin avatar
    51 posts
    Registered:
    14 Aug 2007
    05 Oct 2007
    Link to this post
    Hi.

    I am trying to provide my own custom look to Poll.

    I modified Sitefinity\ControlTemplates\Polls\PollBox.ascx file to include my own html markup. It renders fine on the page. But when I click on Vote button, it throws a null reference exception. Actually, you can see the exception at design time as well......

    Is it a possible bug? Below is my html in PollBox.ascx file:

        <table> 
        <tr> 
            <td><img id="imgSurveyThisWeek" runat="server" src="~/Images/sidebar_thisWeek.png" width="210" height="30" border="0" alt="This week's survey" /></td>  
        </tr> 
        <tr><td><asp:Literal runat="server" ID="pollTitle"></asp:Literal> 
        <asp:Literal runat="server" ID="voteInfo"></asp:Literal> 
        </td></tr>  
        <tr> 
            <!-- This week's survey block --> 
            <td class="surveyBlock">  
                <table> 
                    <asp:Repeater runat="server" ID="questionsList">  
                    <ItemTemplate> 
                        <tr> 
                            <td colspan="2" class="surveyQuestion"><asp:Literal runat="server" ID="questionText" Text='<%# DataBinder.Eval(Container.DataItem, "Text") %>'></asp:Literal></td>  
                        </tr> 
                        <tr> 
                            <td colspan="2">  
                                <asp:PlaceHolder runat="server" ID="answersList"></asp:PlaceHolder> 
                            </td> 
                        </tr> 
                    </ItemTemplate> 
                    </asp:Repeater> 
                    <tr> 
                        <td class="surveyButton"><asp:ImageButton id="voteBtn" runat="server" ImageUrl="~/images/button_vote.gif" ToolTip="Vote" width="110" height="29" border="0" /></td>  
                        <td class="surveyResults"><asp:LinkButton ID="resultsLink" runat="server">View results</asp:LinkButton></td>  
                    </tr> 
                </table> 
            </td> 
        </tr> 
        </table> 

    As always, I appreciate your help!

    Nitin
  2. Nitin
    Nitin avatar
    51 posts
    Registered:
    14 Aug 2007
    05 Oct 2007
    Link to this post
    I thought providing stack trace would help :)

     

    Server Error in '/ThinkwiseInc' Application.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Polls.WebControls.PollBox.Button_Click(Object sender, EventArgs e) +141
       System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +105
       System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +171
       System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833
  3. Nitin
    Nitin avatar
    51 posts
    Registered:
    14 Aug 2007
    05 Oct 2007
    Link to this post
    Ok,

    It looks like it was an oversight at my end. I needed to put the Validator control in <ItemTemplate> </ItemTemplate> tags of questionsList Reeater in my markup.
Register for webinar
3 posts, 0 answered