Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is wrong with my code??

Status
Not open for further replies.

kipster

Technical User
Nov 26, 2001
12
0
0
GB
Hi all

When i run this app, select the checkbox and press the calculate button i get the following error message 'Object reference not set to an instance of an object.'

If i dont select the checkbox and press the calculate button the 2nd page loads with the text 'Bathroom with WC'

Does anyone know what i have done wrong?

<%@ Page Language="VB" Debug="true" Inherits="nihe.SimpleRent" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<html>
<body>
<form runat="server">
Bathroom with W/C:
<asp:CheckBox id="bath_wc" runat="server"></asp:CheckBox>
<p>
<asp:button id="calcbutton" onclick="calculate" runat="server" text="calculate"></asp:button>
</p>
</form>
</body>
</html>

' SimpleRent.vb
'
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace nihe
Public Class SimpleRent : inherits page
protected withevents bath_wc As system.web.ui.webcontrols.checkbox
protected withevents row_bwc As system.web.ui.webcontrols.TableRow

Public sub calculate(source as Object, e as EventArgs)
if bath_wc.checked then
bath_wc.text = "+3"
Context.Items.Add("bath_wc", bath_wc.text)
row_bwc.Visible = bath_wc.checked
end if

server.transfer("SimpleResult.aspx")

End Sub
End Class
End Namespace

<%@ Page Language="vb" %>
<script runat="server">

Sub Page_Load(Source as Object, E as EventArgs)
cell_bwc.text = "Bathroom With WC"
value_bwc.text = Context.Items("bath_wc")
End Sub
</script>
<html>
<body>
<form>
<asp:Table runat="server">
<asp:TableRow id="row_bwc">
<asp:TableCell id="cell_bwc"></asp:TableCell>
<asp:TableCell id ="value_bwc"></asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</html>

Many thanks in advance
 
Jim

How do i know which line causes the error. I am using asp.net web matrix and have debug="true" set in the page directive but all i get is the 'Object reference not set to an instance of an object error message.

Thanks

Kevin
 
Step through the code and debug using breakpoints


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top