unhandled exception

M

Mariame

Hi everyone
I have a strange problem
I have a web page that works good
This web Page contains four buttons each one opens a new page using
script("<script>window.open('page.aspx')</script>")
when i add to this web page another button, when i click it
it give me the error "unhandled exception"
"Object reference not set to an instance of an object"
when i remove this button it still give me the same error when i click other
buttons in this page
Any Idea what could be the problem?????
Thx in Adv
 
H

Hans Kesting

Mariame said:
Hi everyone
I have a strange problem
I have a web page that works good
This web Page contains four buttons each one opens a new page using
script("<script>window.open('page.aspx')</script>")
when i add to this web page another button, when i click it
it give me the error "unhandled exception"
"Object reference not set to an instance of an object"
when i remove this button it still give me the same error when i
click other buttons in this page
Any Idea what could be the problem?????
Thx in Adv

How did you remove that button, just from the html view?

When you add a button in design-mode, VS adds a declaration to the codebehind.
When you remove the button in html-mode, that declaration is not removed.

When you add a serverside onclick handler, then some code is added to
link the button to the handler-method. This code is also not removed when
you remove that button in html-mode. The declaration is still there, so you get
no compiler errors, but in runtime there is no button of that name, so
the link to the handler-code fails with your error message.

How to repair:
1) remove the declaration in the codebehind.
2) open the region "Web Form Designer generated code" and in "InitializeComponent"
search for the line that links the button to the handler code. Remove that line.
3) As the handler code is no longer used, you can remove that also.
(if you do just 1 and/or 3 and then recompile, the compiler will complain about
the line for 2)

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top