473,672 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hi
I have a WebControls.Dro pDownList.
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 1675
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*******@hotm ail.com> wrote in message
news:ip******** *************** *********@4ax.c om...
Hi
I have a WebControls.Dro pDownList.
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*****@infosu pport.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.Fo rm for the collection of form fields.

"Jeff User" <je*******@hotm ail.com> wrote in message
news:31******** *************** *********@4ax.c om...
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*****@infosu pport.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.Ge tValues("_EVENT TARGET").ToStri ng();

Yields error at run time:
Exception Details: System.NullRefe renceException: 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.r illing.net> wrote:
Try Page.Request.Fo rm for the collection of form fields.

"Jeff User" <je*******@hotm ail.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*****@infosu pport.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.Ge tValues("__EVEN TTARGET");
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*******@hotm ail.com>
wrote:

I try this:
string eventVal = "";
eventVal = Request.Form.Ge tValues("_EVENT TARGET").ToStri ng();

Yields error at run time:
Exception Details: System.NullRefe renceException: 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.Fo rm for the collection of form fields.

"Jeff User" <je*******@hotm ail.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*****@infosu pport.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
1521
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 a file. The program copies the files into another dir on the pc the program running on. But now the deleted event is also fired when someone copies a file into the dir and the result is that the file is copied and then deleted. How can I stop...
4
3893
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
1110
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 want to update the Label on the Webpage to indicate the event has occured to all the user that are viewing the Web Page Shreyash
4
1618
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 javascript will be run only in some conditions determine by the input of some webcontrols. Finally the server side event will depend on the chioce of user in the javascript popup. How can i achieve it ?
2
2035
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) { // my server side code;
4
4478
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 server event to fire to update the database. I've successfully done this with a normal webcontrol via: myControl.Attributes("onclick") = "javascript:alert('You clicked me!!');" In that case, myControl is an asp:button on the page. In the...
1
1609
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 information you can provide.
1
2018
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 this information before the event is actually raised? Thanks, Kieron
3
3059
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 asking a lot of these, but I find C# totally way cooler than vb and there''s no go''n back!!!) thanks (as always) kes
0
8488
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8932
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8617
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8686
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7449
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2821
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1821
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.