Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2007, 11:02 PM
Authorized User
 
Join Date: Dec 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bug in the Poll VB code?

After deleted all the poll in local and rerun the page I received error in the BasePoll.vb message:

ArgumentNullException was unhandled by user code
Value cannot be null.

What's happening here?
 
Old April 19th, 2007, 10:06 AM
Authorized User
 
Join Date: Mar 2007
Posts: 39
Thanks: 0
Thanked 1 Time in 1 Post
Default

The two poll boxes on the masterpage require that a poll exist in the DB with the following property values: 'PollID'=24 (hard coded in the 'More Polls' box), and 'IsCurrent'=True (loaded by the 'Current Poll' box). You will need to add at least one poll to the DB with these values in order for TBH to run properly. Because you cannot set the poll ID manually, you will still get a fatal error when the 'More Polls' box looks for a PollID=24. Add the following code to the 'GetPollByID()' function (Poll.vb) to check for a valid poll object, if it is null it returns the current poll instead. This code also prevents the error that occurs adding a pollbox that has an invalid PollID to a WebPart.

Code:
' Returns a Poll object with the specified ID
    Public Shared Function GetPollByID(ByVal pollID As Integer) As Poll
        Dim poll As Poll
        Dim key As String = "Polls_Poll_" + CStr(pollID)

        If BasePoll.Settings.EnableCaching AndAlso Not IsNothing(BizObject.Cache(key)) Then
            poll = CType(BizObject.Cache(key), Poll)
        Else
            poll = GetPollFromPollDetails(SiteProvider.Polls.GetPollByID(pollID))
            'FIX - check for invalid PollID
            If IsNothing(poll) Then
                poll = CurrentPoll 'use current poll if requested poll is invalid
                key = "Polls_Poll_" + CStr(CurrentPollID)
            End If
            BasePoll.CacheData(key, poll)
        End If
        Return poll
    End Function

Additionally the user should not be able to delete the current poll. Also, a dropdown list of existing polls to select from when adding a pollbox in a WebPart would also prevent invalid ID's from locking up the site.
 
Old April 21st, 2007, 08:43 PM
Authorized User
 
Join Date: Dec 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Really appreciate you spent time answear my question.






Similar Threads
Thread Thread Starter Forum Replies Last Post
a big bug on a code busteronline ASP.NET 1.0 and 1.1 Basics 0 September 15th, 2008 09:11 AM
Forum Caching Bug in VB Code Scott663 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 27th, 2008 08:24 PM
Dataview bug? or code error.. nyar C# 1 November 20th, 2006 03:03 PM
VB.NET - oledbcommand.parameters BUG AleBernardi BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 October 9th, 2004 05:56 AM
VB .net or ASP(browser based) / suggestion/poll iniro VB.NET 2002/2003 Basics 3 September 26th, 2004 10:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.