Catch-22 in Web Application

  • Thread starter Thread starter SimeonArgus
  • Start date Start date
S

SimeonArgus

I have a situation that I can't seem to work around. I have a database
that lists the buttons that my application should generate. These
buttons are displayed if certain conditions are met and all previous
button clicks make sense. Sounds simple, right?

Here's the catch. C# Processes FormLoad first, then Button Clicks, so
if I build the page in FormLoad, the wrong buttons may appear, because
the "hide the green buttons" click hasn't been processed to the
database yet.

So I thought about rendering the buttons in PageRender. That runs
after the button clicks have been processed. But when I create the
buttons here, C# doesn't seem to register the button onClick events
with the buttons any more. So it will generate the right buttons, but
clicking them has no effect.

Is there a function, like PageLoad that will always run, but run AFTER
button clicks have been processed, but still will allow me to create
the dynamic button, including a dynamic onClick event?

If not, how can I get around this?

I know it sounds silly, but any direction would be very appreciated!

--Sim
 
You might want to check out the Page Life cycle,http://msdn2.microsoft.com/en-us/library/ms178472.aspx


I checked that, CT. And thus why I was posting. It seems a little odd
that ALLLL of the dynamic content generation must happen before the
page events such as Click events have been processed by the .NET
engine. What if (as in my case) a button click should generate new
content, or possibly reorganize that dynamic content on the page??

I have a solution. Unfortunatlely it requires alot of hidden fields
and alot of javascript on the page, then a new PageLoad in C# code to
process the javascript-managed-hidden-fields on my own. It is a hack,
at best. I was just trying to avoid hacking my page to get what I
thought would be basic functionality.

If I've missed something, PLEASE let me know. I'd rather go back and
do it right than have crappy code out there that is just waiting to
come back and bite me later.

--Sim
 
if you can keep a track of the page was before posting back, you could
create it in the OnLoad Event so you can receive the events, and then clean
everything in the OnPreRender Event and recreate the new buttons there.
That's the only thing I can see that would not be too bhuge to develop and
maintain...

I hope it helps

ThunderMusic
 
Back
Top