error reposting data

  • Thread starter Thread starter Leon
  • Start date Start date
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?
 
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 abig
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?
 
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
 
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?
 
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
 
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!
 
Back
Top