I'm working on a commenting system for a website and on each postback a page generates a user control (called ucComment) for every single comment in the database that pertains to this page. Each ucComment has a Respond button that allows you to respond to each individual comment.
I was having a problem with the Respond button not doing anything when I finally realized that every time a new comment was created, the next postback it would offset all the page's control IDs. In other words, when I click on ctl00_Content_ctl00_ctl01_ctl0*7*_lbtnRespond, that control would actually be generated as ctl00_Content_ctl00_ctl01_ctl0*8*_lbtnRespond on the next postback. So the event associated with ctl07 would simply not happen.
While poking around on the web, I read about overriding the ClientID. I thought if I could name the controls the way I wanted to, I could circumvent my problem. http://west-wind.com/Weblog/posts/4605.aspx It looked like a great hack but it doesn't fire events because of the disparity between the generated ID on the page and how the ID was represented in the control tree.
there's even a guy who derived from MasterPage to change the way that the control tree works to get the above hack to work for postbacks: http://www.netquarry.com/index.php/2009/03/master-pages-ajax-and-javascript-10292/ but i fear that there may be untold repercussions.
What should I do to get my commenting system working such that I can respond to a specific comment and have the respond event still fire even if the control is renamed on that postback?