473,382 Members | 1,736 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,382 software developers and data experts.

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 1662
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: petterl | last post by:
I have a program that watching a directory and its sub directories. So far I have got it to work to report when someone copies a file into it, but now i also want to be notified when someone delete...
4
by: Anatoly | last post by:
Put any control on web page. create Init event for ths control. Write Response.Write("here") inside this event. Compile\build\run. I never saw "here" string appear on web page. Why???
2
by: Shreyash Patel | last post by:
Hi I have a label on my WebPage. When Event A occurs on the Server I want to update the information in the label. So the Event A is not a client event but an event that occurs on the Server. So I...
4
by: Lau Alvin | last post by:
HI all , I want to make a button which have a server side OnClick event in .cs to update the DB. But I want it to have a client side onclick event to run a javascript popup too. And the...
2
by: Eli | last post by:
Hello. I have a server side event Page_Load in aspx page. <%@ Page Languadge=c# AutoEventWireup="true" %> <script Languadge=c# runat=server> void Page_Load(Object sender, EventArgs e) { //...
4
by: Barb | last post by:
I have a user control as my Save button for my page. When the Save button is clicked, I want some client-side validation to take place from a javascript function in the page, and then I'd like the...
1
by: Rodney | last post by:
I want to notify browser of every time my server side event fires w/o creating some sort of timer on client. Basically, can server notify client w/o client initiating contact? Again, thx for any...
1
by: =?Utf-8?B?S2llcm9u?= | last post by:
Hi, How do I reliably find the name of the event (e.g Click, SelectedIndexChanged etc) that caused a page to post back. Is there somewhere in the Asp.Net pipelines we can hook into and discover...
3
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
In the page_load event i need to see which event fired the post back. what here allows this. I specificly want to know if the enter key was pressed. but i need to check for others. -- (i''ll be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.