Handling events on automatically generated web controls

J

JezB

I am dynamically creating WebControls and creating them on my page. Some of
these are buttons, and I attach events to these buttons. The problem is
these force a post-back, so I must regenerate all the webcontrols in the
same way (I am assuming - am I right?).

It was all working fine but now I get the error:

"An error has occurred because a control with auto-generated id '_ctl129'
could not be located to raise a postback event. To avoid this error,
explicitly set the ID property of controls that raise postback events."

occurring between Page_Load and actually firing the event. I can basically
understand why but I dont know why it was working and now it isnt (I just
added some code to evaluate a dataset in generating the webcontrols - if I
take this out it works again).

What can I do about it ?
 
J

JezB

Incidentally, I have tried generating IDs for my buttons as the error
suggests but this doesnt help. Same thing happens.
 
I

Ireney Berezniak

JezB said:
Incidentally, I have tried generating IDs for my buttons as the error
suggests but this doesnt help. Same thing happens.
What dynamic method are you using to create those web controls? Adding
them to a repeater maybe? Loading from a path? When you say
WebControls, I'm assuming you mean the intrinsic controls, such as
asp:textbox or are you maybe talking about Customr Web Controls you
created, or Custome User Controls? Too many pieces missing to give you
a definite answer ... a code sample would help.

ib.
 
J

JezB

I got round it by saving my HtmlTable object in session, then on postpack
reinstating it and adding it again to the placeholder (rather than going
through the loop again).
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top