Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Question re Event Firing Sequence

Reply
Thread Tools

Question re Event Firing Sequence

 
 
Phillip N Rounds
Guest
Posts: n/a
 
      03-01-2006
In diagnosing a problem, I noted that a button_click event gets run only
after the page Page_Load event of the post back. (VS 2003, ASPNET 1.1, C#)

Can this be correct? I'm trying to set session variables in a Button_Click
event which determines how the page is supposed to appear in the PostBack,
so of course it fails.

Where should I put my code so that the session variables are re-set before
the PostBack?

Thanks

Phil


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      03-02-2006
This is correct.

You can't do anything BEFORE the postback, since it is the postback that
cause your application to run. You probably mean "in the beginning" of the
postback handling code. Just put it in the beginning of Page_Load event, if
you can. If you need to know what caused the postback, you can check
Request.Form["__EVENTTARGET"] (works in most cases, but there are
exceptions), or pass it in your own hidden input.

Eliyahu

"Phillip N Rounds" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In diagnosing a problem, I noted that a button_click event gets run only
> after the page Page_Load event of the post back. (VS 2003, ASPNET 1.1,
> C#)
>
> Can this be correct? I'm trying to set session variables in a
> Button_Click event which determines how the page is supposed to appear in
> the PostBack, so of course it fails.
>
> Where should I put my code so that the session variables are re-set
> before the PostBack?
>
> Thanks
>
> Phil
>
>



 
Reply With Quote
 
 
 
 
Phillip N Rounds
Guest
Posts: n/a
 
      03-02-2006
Sorry, my post wasn't specific enough. I was trying to shorten a previous 2
page post and got overly terse.

I'm writing a user control which has two states: Active & InActive. I
additionally am required that there to be only one active control per page,
and all logic has to be contained within the control.
In its inactive state, only a single button appears. If the user clicks on
this button, the control becomes active( the rest of the control's
functionality becomes visible), and all other controls should become
inactive. When the user is finished with a control, they click the 'Done'
button, and the control becomes inactive.

I'm trying to do this by having a session variable for each control,
Session[ this.ControlID + "_ActiveState"] = { 0, 1 } and a single session
variable
Session[ "WhichControlIsActive "] = { 'None', "ControlID_1", "ControlID2",
.... , "ControlID_N" }

When the user selects an inactive control, its Session[ this.ControlID +
"_ActiveState"] gets set to 1 in the Control.ActivateButton_Click(..)
method, and Session[ "WhichControlIsActive" ] = this.ControlID;, and the
page gets posted back.

When the user is finished and clicks the 'Done' button, Session[
this.ControlID +"_ActiveState"] get set to 0, Session[
"WhichControlIsAcitve"] get set to 'None', and the page gets posted back.

I now want the new page to reflect the new session variables. My problem is
that the new session variables don't get saved until after the Page_Load
event of the new page, so these session variables are useless in structuring
the subsequent pages.

I can't use hidden fields, because they would have to be in a public place
( i.e. the containing page ), and I'm required to have all logic internal.
Similarly,
the Request.Form["_ "] isn't available to the controls.

Is there really no good way to do this?


"Eliyahu Goldin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This is correct.
>
> You can't do anything BEFORE the postback, since it is the postback that
> cause your application to run. You probably mean "in the beginning" of the
> postback handling code. Just put it in the beginning of Page_Load event,
> if you can. If you need to know what caused the postback, you can check
> Request.Form["__EVENTTARGET"] (works in most cases, but there are
> exceptions), or pass it in your own hidden input.
>
> Eliyahu
>
> "Phillip N Rounds" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> In diagnosing a problem, I noted that a button_click event gets run only
>> after the page Page_Load event of the post back. (VS 2003, ASPNET 1.1,
>> C#)
>>
>> Can this be correct? I'm trying to set session variables in a
>> Button_Click event which determines how the page is supposed to appear in
>> the PostBack, so of course it fails.
>>
>> Where should I put my code so that the session variables are re-set
>> before the PostBack?
>>
>> Thanks
>>
>> Phil
>>
>>

>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      03-05-2006
First, I think Request.Form["_ "] should be available for controls as long
as controls can get a pointer to the page they are on. Furthermore, the
UserControl class already has property Request.

Second, you don't need to access Request.Form["_ "] from the control in the
first place, just do it in the Page_Load event and you will now what control
initiated the postback.

Am I again missing something?

Eliyahu

"Phillip N Rounds" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Sorry, my post wasn't specific enough. I was trying to shorten a previous
> 2 page post and got overly terse.
>
> I'm writing a user control which has two states: Active & InActive. I
> additionally am required that there to be only one active control per
> page, and all logic has to be contained within the control.
> In its inactive state, only a single button appears. If the user clicks
> on this button, the control becomes active( the rest of the control's
> functionality becomes visible), and all other controls should become
> inactive. When the user is finished with a control, they click the 'Done'
> button, and the control becomes inactive.
>
> I'm trying to do this by having a session variable for each control,
> Session[ this.ControlID + "_ActiveState"] = { 0, 1 } and a single session
> variable
> Session[ "WhichControlIsActive "] = { 'None', "ControlID_1", "ControlID2",
> ... , "ControlID_N" }
>
> When the user selects an inactive control, its Session[ this.ControlID +
> "_ActiveState"] gets set to 1 in the Control.ActivateButton_Click(..)
> method, and Session[ "WhichControlIsActive" ] = this.ControlID;, and the
> page gets posted back.
>
> When the user is finished and clicks the 'Done' button, Session[
> this.ControlID +"_ActiveState"] get set to 0, Session[
> "WhichControlIsAcitve"] get set to 'None', and the page gets posted back.
>
> I now want the new page to reflect the new session variables. My problem
> is that the new session variables don't get saved until after the
> Page_Load event of the new page, so these session variables are useless in
> structuring the subsequent pages.
>
> I can't use hidden fields, because they would have to be in a public place
> ( i.e. the containing page ), and I'm required to have all logic internal.
> Similarly,
> the Request.Form["_ "] isn't available to the controls.
>
> Is there really no good way to do this?
>
>
> "Eliyahu Goldin" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> This is correct.
>>
>> You can't do anything BEFORE the postback, since it is the postback that
>> cause your application to run. You probably mean "in the beginning" of
>> the postback handling code. Just put it in the beginning of Page_Load
>> event, if you can. If you need to know what caused the postback, you can
>> check Request.Form["__EVENTTARGET"] (works in most cases, but there are
>> exceptions), or pass it in your own hidden input.
>>
>> Eliyahu
>>
>> "Phillip N Rounds" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> In diagnosing a problem, I noted that a button_click event gets run only
>>> after the page Page_Load event of the post back. (VS 2003, ASPNET 1.1,
>>> C#)
>>>
>>> Can this be correct? I'm trying to set session variables in a
>>> Button_Click event which determines how the page is supposed to appear
>>> in the PostBack, so of course it fails.
>>>
>>> Where should I put my code so that the session variables are re-set
>>> before the PostBack?
>>>
>>> Thanks
>>>
>>> Phil
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
firing button click event before page load event.....???? GauravGupta ASP .Net 4 01-19-2012 06:52 AM
TkInter bind() event is not firing event trigger Anthony Papillion Python 3 06-23-2010 12:55 AM
how to iterate over sequence and non-sequence ? stef mientki Python 13 10-20-2007 10:21 AM
PostBack Event Firing Sequence Guadala Harry ASP .Net 3 08-15-2004 07:42 AM
BOOT SEQUENCE (how to change boot sequence) bird Computer Support 13 12-24-2003 02:20 AM



Advertisments