For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > April 2006 > Re: how do I know it's posted back due to a button click in Form_L









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: how do I know it's posted back due to a button click in Form_L
Damien

2006-04-28, 8:07 am

Jazz wrote:
> Paul,
> What I want is to detect if it's from ButtonA click in the Form_Load
> even(this is before the ButtonCLick event gets called), and if it is I will
> skip some code in the Form_Load .
>
> Thanks,
> Jazz


In VB:

If Not Request.Params("ButtonA") is Nothing Then
'Do stuff if button A was pressed
Else
'Do stuff if button A wasn't pressed
End If

However, I wouldn't recommend it. You've now, potentially, got two
places where code reacts to button presses - in the Page Load event and
in the button Click event. A future maintainer (or a future you) may be
if they don't spot the code in Page Load, and spend valuable
time trying to diagnose why the page acts differently when the button
is pressed.

Perhaps if you could elaborate on what behaviour you're altering, we
could suggest some viable alternatives?

Damien

Bill Gregg

2006-04-28, 7:05 pm


In the Form Load event handler, can't you interrogate the sender object
to determine whether or not button A was pressed?

Bill


*** Sent via Developersdex http://www.developersdex.com ***
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com