473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Catch-22 in Web Application

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

Mar 16 '07 #1
3 1458
You might want to check out the Page Life cycle,
http://msdn2.microsoft.com/en-us/library/ms178472.aspx

--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS
"SimeonArgus" <si*********@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
>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

Mar 18 '07 #2
On Mar 18, 11:10 am, "<ct>" <carstentATintegratedsolutions.dkwrote:
You might want to check out the Page Life cycle,http://msdn2.microsoft.com/en-us/library/ms178472.aspx

--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS"SimeonArgus" <simeontr...@gmail.comwrote in message

news:11**********************@l77g2000hsb.googlegr oups.com...
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

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

Mar 19 '07 #3
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
"SimeonArgus" <si*********@gmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...
On Mar 18, 11:10 am, "<ct>" <carstentATintegratedsolutions.dkwrote:
>You might want to check out the Page Life
cycle,http://msdn2.microsoft.com/en-us/library/ms178472.aspx

--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS"SimeonArgus" <simeontr...@gmail.comwrote in message

news:11**********************@l77g2000hsb.googleg roups.com...
>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


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

Mar 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Gary.Hu | last post by:
I was trying to catch the Arithmetic exception, unsuccessfully. try{ int a = 0, b = 9; b = b / a; }catch(...){ cout << "arithmetic exception was catched!" << endl; } After ran the program,...
11
by: kaeli | last post by:
Hey all, I'd like to start using the try/catch construct in some scripts. Older browsers don't support this. What's the best way to test for support for this construct so it doesn't kill...
4
by: Abhishek Srivastava | last post by:
Hello All, I have seen code snippets like try { ..... } catch {
11
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
13
by: Benny | last post by:
Hi, I have something like this: try { // some code } catch // note - i am catching everything now {
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
13
by: Bit byte | last post by:
Is there any way of retrievieng error information (say, from a 'global' or system wide) error object - when you are in a catch all statement block? Sometimes it cannot be helped, when something...
7
by: dick | last post by:
in the "try{throw}catch" structure, how the C++ code return the "type" thrown by a function?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.