who can explain?

  • Thread starter Thread starter AlexS
  • Start date Start date
A

AlexS

Here is the problem:

An error has occurred because a control with auto-generated id '_ctl2' could
not be located to raise a postback event. To avoid this error, explicitly
set the ID property of controls that raise postback events.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: An error has occurred because a
control with auto-generated id '_ctl2' could not be located to raise a
postback event. To avoid this error, explicitly set the ID property of
controls that raise postback events.

Source Error:


An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.


Stack Trace:


[HttpException (0x80004005): An error has occurred because a control with
auto-generated id '_ctl2' could not be located to raise a postback event. To
avoid this error, explicitly set the ID property of controls that raise
postback events.]
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean
fBeforeLoad) +851
System.Web.UI.Page.ProcessRequestMain() +878





----------------------------------------------------------------------------
----

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573

What is the proper way to correct this? I found one solution, which looks
stupid enough:

related control, before adding it to Controls collection of page should be
assigned specific ID string,

maycontrol=new Web.UI.Controls.ImageButton();
mycontrol.ID="myid";
this.Controls.Add(mycontrol);

Then this exception disappears.

But bewilderment doesn't!!!!!
 
I'm not familiar with COM, but it looks like it wants you
to explicitly set the <Assembly: Guid("")> attribute that
is in the AssemblyInfo.vb (in VB) file that is auto-
generated with a new project. I guess auto-generated
GUIDs aren't good enough for objects that are exposed to
COM in the unlikely event that there will be a
duplicate. Hope that helps.

Stephen
-----Original Message-----
Here is the problem:

An error has occurred because a control with auto- generated id '_ctl2' could
not be located to raise a postback event. To avoid this error, explicitly
set the ID property of controls that raise postback events.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: An error has occurred because a
control with auto-generated id '_ctl2' could not be located to raise a
postback event. To avoid this error, explicitly set the ID property of
controls that raise postback events.

Source Error:


An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.


Stack Trace:


[HttpException (0x80004005): An error has occurred because a control with
auto-generated id '_ctl2' could not be located to raise a postback event. To
avoid this error, explicitly set the ID property of controls that raise
postback events.]
System.Web.UI.Page.ProcessPostData
(NameValueCollection postData, Boolean
 
Back
Top