Mystery ASP.NET Error

A

Amelyan

this question may be more appropriate for this group.

How do I force my Page to Page_Load when user clicks browser's Back button?
I am trying to avoid this error, that I get when I hit back button on my
browser and click on my dynamically generated button:

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

I did Google on this error, but nothing useful came up. At this time, I
have a theory that this results from the fact that when I click Back button,
my Page_Load function doesn't get invoked (page is cached). Then when I
click on my dynamically generated control on the page, I get that error
message.

I did several posts on this already. However, no one seems to have the
slightest clue of what exactly going on when this error is generated.


Amelyan

ps> Please keep in mind that the error only occurs when I click Back button
on my browser, then click my dynamically generated button again. Otherwise,
it is working just fine.
 
V

Visar Gashi, MCP

Hello,

Are you always remaining in the same page during operation?

If you are only working on the same page and during operation someone is
clicking the "back" button, you can avoid this by setting smart navigation
"on", that way the clicks on that page don't enter the history and the back
button cannot be pressed.

If you do need to press the "back" button, then set the cache timeout for
the page to zero, see if that helps:

E.g.:
<%@ OutputCache Duration="0" Location="Any" VaryByParam="" %>

Regards,
-Visar
 
B

B Amelyan

Visar,


Yes, I am always staying on the same page. I just reload a different
set of controls on post back. So, when someone clicks the back button,
he gets the previous set of controls (without going through post back,
probably via page caching), and that is when the error occurs when user
tries to click control on the page brought from the cache.

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

I understand that it happens this way especially after your explanation.
However, I am also trying to understand why it happens this way, i.e.
why it results in this particular error.


Thank you,
Amelyan
 
A

Amelyan

It generates the following error

The 'duration' attribute must be set to a positive integer value
 
V

Visar Gashi, MCP

I have not tried using a chace of 0 before, but you can manipulate the cache
directly from your code using the Response.Cache. This will give you much
more controll over the cached page.

Regards,
-Visar
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top