CH06\SwitchCase.aspx
I am reading the book and have come across an example that bombs if you donât enter a selection. It is CH06\SwitchCase.aspx which (also has a missing â}â ) bombs with the following error message if no selection is initially made from the radio list:
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 5: if (Page.IsPostBack)
Line 6: {
Line 7: switch(Destination.SelectedItem.Value)
Line 8: {
Line 9: case "Barcelona":
Source File: D:\ASPCode\Library\Books\BegASPNET\CH06\SwitchCase .aspx Line: 7
I have struggled with it for some time and seem to have figured out that the either the object âDestinationâ isnât created or the Destination.SelectedItem.Value is not created in this situation. Is this correct? Is there a workaround for this situation? Can you please explain?
Thanks in advance.
-Malcolm
Malcolm Donald, Pres.
Accelerant, Inc.
508.540.5830
|