error reposting data

L

Leon

Hi everybody.

I am adding image buttons to my web form programmatically and adding
onclientclick for each button to call java function to save some info. When
form is reposted I get an error message:

An error has occurred because a control with id
'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different control
is assigned to the same ID after postback. If the ID is not assigned,
explicitly set the ID property of controls that raise postback events to
avoid this error.

Probably I get this message, because on repost I do not recreate those image
buttons and I do not need to recreate them, because I need to show just a big
picture of the product.

How can I avoid this problem?
 
G

Guest

Hi everybody.

I am adding image buttons to my web form programmatically and adding
onclientclick for each button to call java function to save some info. When
form is reposted I get an error message:

An error has occurred because a control with id
'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different control
is assigned to the same ID after postback. If the ID is not assigned,
explicitly set the ID property of controls that raise postback events to
avoid this error.

Probably I get this message, because on repost I do not recreate those image
buttons and I do not need to recreate them, because I need to show just a big
picture of the product.

How can I avoid this problem?

Did you add unique id to each control when you create it from the code?
 
S

S. Justin Gengo

Leon

If it's a javascript call that's being made from the button and there is no
need to post back to the server then you could correct this error by
stopping the post-back altogether by adding: "return false;" to your
javascript called from the button.

However if someone has javascript turned off then the postback will still
occur and if you don't recreated the dynamic controls in .net you will
always get the error.

--


Sincerely,

S. Justin Gengo, MCP

Free code library at:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
L

Leon

I do need to postback. I need to show a large picture of selected product. Is
there any other way to do the same thing?
 
S

S. Justin Gengo

Leon,

If you need to re-post dot net wants to automatically check the values of
the controls posted back. So you'll need to re-create the dynamic controls
each time. That's what dot net would do if the controls were added to the
page normally so you aren't creating more work than normal. You're just
re-creating them on your own rather than using the framework to do so.


--


Sincerely,

S. Justin Gengo, MCP

Free code library at:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

No. I did not. Would it help if I did?






- Show quoted text -

Yes, it helped as you can see. It was also mentioned in the error
message you got: "If the ID is not assigned, explicitly set the ID
property of controls that raise postback events to avoid this error".
Glad, that it helps,

Cheers!
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top