Object reference not set to an instance of an object.

K

Kiran More

WebControl button = (WebControl)Page.FindControl("btn_Delete");

button.Attributes.Add("onclick", "return confirmDelete (this.form);");

confirmDelete is the method written in Javascript.


I am getting following error message as,

Object reference not set to an instance of an object.
 
Y

Yvonne

Hy Kiran,
Are you sure that this control exists on the page? FindControl returns
a null reference if it doesn't find the control. This seems to be your
problem, that is the caus of your exception.
Yvonne
 
M

MikeS

Maybe just set the OnClientClick property of the button instead of
going to the trouble of trying to find it.
 

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

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top