Monday, March 26, 2012

Strange Error

Hey folks, I'm receiving a strange error when I press the submit button web control on my page. As of now, the button doesn't contain any code. Here is the error message.

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

The page consists of a dynamically created table web control in codebehind - that's it.

Instead of posting code and seeing what's wrong with it (if anything), I'm just curious if anyone has ever had experience with this message. I googled and found very little, and the one guy who resolved his issue said "Ah, the error message had nothing to do with the real problem..." but doesn't explain what he did to correct it.I managed to find a way around my problem. Due to the architecture of this project, I have to avoid some of the things that make .NET easier for everyone - viewstate and querystrings. The page prior to this one submitted to it via Javascript, so when my page loaded, I would Request.Form() on any of the items that I needed.

Solution:

I ditched the Javascript part of it, by implementing ASP.NET's button web control, and redirected to the page using a querystring instead. Then on the Page_Load, I just retrieved the querystring values, and populated the necessary variables.

0 comments:

Post a Comment