469,950 Members | 2,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

how to determine (on server) which (client) event fired

Hi
I have a WebControls.DropDownList.
autoPostBack is set to true.
I have code (C#) in the event procedure in the code behind and it
works fine. OK, now my problem is this:
While in the Page_Load event, I want to be able to determine, what
event, if any, caused the page to be loading.
ie. maybe there are several possible user control events that could
have occured. Which one brought me here?
So
If the DropDown (index changed, or whatever event) ran before the
Page_Load, I would know that this event fired (because I would be in
the DropDown event procedure) and I could set a flag or whatever but,
when this event fires and posts back, the Page_Load event runs before
the DropDown event.

So how, can I determine what event just fired, before I get to its
specific event procedure?

Thanks
Jeff
Nov 27 '05 #1
6 1559
All the information you need should be in the posted form data. Take a look
at the form fields passed to your code and see if you can parse that
information.
"Jeff User" <je*******@hotmail.com> wrote in message
news:ip********************************@4ax.com...
Hi
I have a WebControls.DropDownList.
autoPostBack is set to true.
I have code (C#) in the event procedure in the code behind and it
works fine. OK, now my problem is this:
While in the Page_Load event, I want to be able to determine, what
event, if any, caused the page to be loading.
ie. maybe there are several possible user control events that could
have occured. Which one brought me here?
So
If the DropDown (index changed, or whatever event) ran before the
Page_Load, I would know that this event fired (because I would be in
the DropDown event procedure) and I could set a flag or whatever but,
when this event fires and posts back, the Page_Load event runs before
the DropDown event.

So how, can I determine what event just fired, before I get to its
specific event procedure?

Thanks
Jeff

Nov 27 '05 #2
Hi Jeff,

take a look at the __EVENTTARGET posted value. It contains the ID of
control which is being posted to.

Grtz, Wouter van Vugt
Info Support
www.dive-in-it.nl

Nov 27 '05 #3
Thanks guys

How do I get to the _EVENTTARGET value?

I was trying to use Context.Request.Params
but couldnt figure out what to do after Params.
Context.Request.Params.Keys? but not sure what to do with/after Keys?

Can anyone help me structure this statement? I did not find any
examples at all.

Thanks again
Jeff
On 27 Nov 2005 04:37:09 -0800, "Wouter van Vugt"
<wo*****@infosupport.com> wrote:
Hi Jeff,

take a look at the __EVENTTARGET posted value. It contains the ID of
control which is being posted to.

Grtz, Wouter van Vugt
Info Support
www.dive-in-it.nl


Nov 27 '05 #4
Try Page.Request.Form for the collection of form fields.

"Jeff User" <je*******@hotmail.com> wrote in message
news:31********************************@4ax.com...
Thanks guys

How do I get to the _EVENTTARGET value?

I was trying to use Context.Request.Params
but couldnt figure out what to do after Params.
Context.Request.Params.Keys? but not sure what to do with/after Keys?

Can anyone help me structure this statement? I did not find any
examples at all.

Thanks again
Jeff
On 27 Nov 2005 04:37:09 -0800, "Wouter van Vugt"
<wo*****@infosupport.com> wrote:
Hi Jeff,

take a look at the __EVENTTARGET posted value. It contains the ID of
control which is being posted to.

Grtz, Wouter van Vugt
Info Support
www.dive-in-it.nl

Nov 28 '05 #5

I try this:
string eventVal = "";
eventVal = Request.Form.GetValues("_EVENTTARGET").ToString();

Yields error at run time:
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Doesn't matter if this executed during postback or not.

Any details that anyone could provide is much appreciated.

Thanks again


On Sun, 27 Nov 2005 15:52:22 -0800, "Peter Rilling"
<pe***@nospam.rilling.net> wrote:
Try Page.Request.Form for the collection of form fields.

"Jeff User" <je*******@hotmail.com> wrote in message
news:31********************************@4ax.com.. .
Thanks guys

How do I get to the _EVENTTARGET value?

I was trying to use Context.Request.Params
but couldnt figure out what to do after Params.
Context.Request.Params.Keys? but not sure what to do with/after Keys?

Can anyone help me structure this statement? I did not find any
examples at all.

Thanks again
Jeff
On 27 Nov 2005 04:37:09 -0800, "Wouter van Vugt"
<wo*****@infosupport.com> wrote:
Hi Jeff,

take a look at the __EVENTTARGET posted value. It contains the ID of
control which is being posted to.

Grtz, Wouter van Vugt
Info Support
www.dive-in-it.nl


Nov 28 '05 #6
Fixed it!

sEventTarget = Request.Form.GetValues("__EVENTTARGET");
now works. Although .ToString() on the end was not correct,it was
not the problem. The problem was that the name of the value that I
wanted contains 2 underscores "__", and I was only using 1 "_".

Thanks for the guidance
Jeff
On Mon, 28 Nov 2005 02:04:54 GMT, Jeff User <je*******@hotmail.com>
wrote:

I try this:
string eventVal = "";
eventVal = Request.Form.GetValues("_EVENTTARGET").ToString();

Yields error at run time:
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Doesn't matter if this executed during postback or not.

Any details that anyone could provide is much appreciated.

Thanks again


On Sun, 27 Nov 2005 15:52:22 -0800, "Peter Rilling"
<pe***@nospam.rilling.net> wrote:
Try Page.Request.Form for the collection of form fields.

"Jeff User" <je*******@hotmail.com> wrote in message
news:31********************************@4ax.com. ..
Thanks guys

How do I get to the _EVENTTARGET value?

I was trying to use Context.Request.Params
but couldnt figure out what to do after Params.
Context.Request.Params.Keys? but not sure what to do with/after Keys?

Can anyone help me structure this statement? I did not find any
examples at all.

Thanks again
Jeff
On 27 Nov 2005 04:37:09 -0800, "Wouter van Vugt"
<wo*****@infosupport.com> wrote:

Hi Jeff,

take a look at the __EVENTTARGET posted value. It contains the ID of
control which is being posted to.

Grtz, Wouter van Vugt
Info Support
www.dive-in-it.nl


Nov 28 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by petterl | last post: by
4 posts views Thread by Anatoly | last post: by
2 posts views Thread by Shreyash Patel | last post: by
2 posts views Thread by Eli | last post: by
4 posts views Thread by Barb | last post: by
1 post views Thread by =?Utf-8?B?S2llcm9u?= | last post: by
3 posts views Thread by =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.