[Last Call] Learn how to a build a cloud-first strategyRegister Now


Quiz Error: XML /System.NullReferenceException

Posted on 2008-11-04
Medium Priority
Last Modified: 2013-11-08

I am trying to use Enrico's asp.net online quiz script but keep getting an error.


 The page loads in for the first time ok with the question showing but when i click the submit button I get this error:


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:

Line 42:
Line 43:       'Correct answer?
Line 44:       If rblAnswer.SelectedItem.Value = ViewState("CorrectAnswer") Then
Line 45:             intScore += 1
Line 46:             arrAnswerHistory.Add(0)

 What does this mean?  How do I fix it?



Question by:Tania_Farmer
LVL 13

Expert Comment

ID: 22883437
Which line is throwing the exception ?
Your problem be that arrAnswerHistory is null. If you set a break point there and run your page in debug you'll probably see that arrAnswerHistory=null and you try to use it anyway.
LVL 14

Accepted Solution

Binuth earned 2000 total points
ID: 22883450
check page view state is enabled
if no, enable the page level viewstate

<%@ Page EnableViewState="true" %>

Author Comment

ID: 22883511
That did it - thanks!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month18 days, 5 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question