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

Find out the control that initiated the postback event

Dan
Hi,

I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no references as to how to do it this way as I already know how.

I know this may be getting into advanced or unheard of territory.

I have some custom web user controls that are dynamically created at run time along with other controls. I can still add an event handler to these controls, but unfortunately the event handler wont fire until the controls are re-created on the postback, but I don't want the start-up code running on a post back, I need it to run in the event of the control that cuased the post back. This works fine for my other controls on the form that arn't generated, but will not for this user control, so I need an alternative.

I need some indication in my page_load (or init) event that tells me that our user control has initiated the postback and to then run start up code.

Are there any techniques out there that allow me to dig into the postback and discover what control or control type made the postback?

Another solution I could add a client side handler that could set the value of a checkbox but due to the complexity of the user control I am not going to do that, as a post back could be initiated by a multiple number of events on different controls within the user control.

Thats my question! Thanks..
Nov 18 '05 #1
5 4789
You should be able to add an eventhandler, but if you don't want to you can use Request.Form("__EVENTTARGET"). You must have a control on your form that renders the function __doPostBack(eventTarget, eventArgument) on your page. Many controls will put the function on your page. You could always put a dummy control like a linkbutton or something on your page to force the script to be rendered. Hope this helps.

"Dan" <no********@nowhere.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no references as to how to do it this way as I already know how.

I know this may be getting into advanced or unheard of territory.

I have some custom web user controls that are dynamically created at run time along with other controls. I can still add an event handler to these controls, but unfortunately the event handler wont fire until the controls are re-created on the postback, but I don't want the start-up code running on a post back, I need it to run in the event of the control that cuased the post back. This works fine for my other controls on the form that arn't generated, but will not for this user control, so I need an alternative.

I need some indication in my page_load (or init) event that tells me that our user control has initiated the postback and to then run start up code.

Are there any techniques out there that allow me to dig into the postback and discover what control or control type made the postback?

Another solution I could add a client side handler that could set the value of a checkbox but due to the complexity of the user control I am not going to do that, as a post back could be initiated by a multiple number of events on different controls within the user control.

Thats my question! Thanks..
Nov 18 '05 #2
Dan
the items do actually exist in the Request.Form collection...

but are ""
"vMike" <Mi************@gewarren.com.nospam> wrote in message news:bq**********@ngspool-d02.news.aol.com...
You should be able to add an eventhandler, but if you don't want to you can use Request.Form("__EVENTTARGET"). You must have a control on your form that renders the function __doPostBack(eventTarget, eventArgument) on your page. Many controls will put the function on your page. You could always put a dummy control like a linkbutton or something on your page to force the script to be rendered. Hope this helps.

"Dan" <no********@nowhere.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no references as to how to do it this way as I already know how.

I know this may be getting into advanced or unheard of territory.

I have some custom web user controls that are dynamically created at run time along with other controls. I can still add an event handler to these controls, but unfortunately the event handler wont fire until the controls are re-created on the postback, but I don't want the start-up code running on a post back, I need it to run in the event of the control that cuased the post back. This works fine for my other controls on the form that arn't generated, but will not for this user control, so I need an alternative.

I need some indication in my page_load (or init) event that tells me that our user control has initiated the postback and to then run start up code.

Are there any techniques out there that allow me to dig into the postback and discover what control or control type made the postback?

Another solution I could add a client side handler that could set the value of a checkbox but due to the complexity of the user control I am not going to do that, as a post back could be initiated by a multiple number of events on different controls within the user control.

Thats my question! Thanks..
Nov 18 '05 #3
Dan
Thanks for the reply,

although sounds nice in theory.

I tried it and in every instance of a post back

Diagnostics.Debug.WriteLine(Request.Form("__EVENTT ARGET"))

Diagnostics.Debug.WriteLine(Request.Form("__EVENTA RGUMENT"))

both return a blank string..

Any ideas ?

"vMike" <Mi************@gewarren.com.nospam> wrote in message news:bq**********@ngspool-d02.news.aol.com...
You should be able to add an eventhandler, but if you don't want to you can use Request.Form("__EVENTTARGET"). You must have a control on your form that renders the function __doPostBack(eventTarget, eventArgument) on your page. Many controls will put the function on your page. You could always put a dummy control like a linkbutton or something on your page to force the script to be rendered. Hope this helps.

"Dan" <no********@nowhere.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no references as to how to do it this way as I already know how.

I know this may be getting into advanced or unheard of territory.

I have some custom web user controls that are dynamically created at run time along with other controls. I can still add an event handler to these controls, but unfortunately the event handler wont fire until the controls are re-created on the postback, but I don't want the start-up code running on a post back, I need it to run in the event of the control that cuased the post back. This works fine for my other controls on the form that arn't generated, but will not for this user control, so I need an alternative.

I need some indication in my page_load (or init) event that tells me that our user control has initiated the postback and to then run start up code.

Are there any techniques out there that allow me to dig into the postback and discover what control or control type made the postback?

Another solution I could add a client side handler that could set the value of a checkbox but due to the complexity of the user control I am not going to do that, as a post back could be initiated by a multiple number of events on different controls within the user control.

Thats my question! Thanks..
Nov 18 '05 #4
Are the control(s) within the form tags?
"Dan" <no********@nowhere.com> wrote in message news:%2***************@tk2msftngp13.phx.gbl...
the items do actually exist in the Request.Form collection...

but are ""
"vMike" <Mi************@gewarren.com.nospam> wrote in message news:bq**********@ngspool-d02.news.aol.com...
You should be able to add an eventhandler, but if you don't want to you can use Request.Form("__EVENTTARGET"). You must have a control on your form that renders the function __doPostBack(eventTarget, eventArgument) on your page. Many controls will put the function on your page. You could always put a dummy control like a linkbutton or something on your page to force the script to be rendered. Hope this helps.

"Dan" <no********@nowhere.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no references as to how to do it this way as I already know how.

I know this may be getting into advanced or unheard of territory.

I have some custom web user controls that are dynamically created at run time along with other controls. I can still add an event handler to these controls, but unfortunately the event handler wont fire until the controls are re-created on the postback, but I don't want the start-up code running on a post back, I need it to run in the event of the control that cuased the post back. This works fine for my other controls on the form that arn't generated, but will not for this user control, so I need an alternative.

I need some indication in my page_load (or init) event that tells me that our user control has initiated the postback and to then run start up code.

Are there any techniques out there that allow me to dig into the postback and discover what control or control type made the postback?

Another solution I could add a client side handler that could set the value of a checkbox but due to the complexity of the user control I am not going to do that, as a post back could be initiated by a multiple number of events on different controls within the user control.

Thats my question! Thanks..
Nov 18 '05 #5
then the postback was caused by a submit button (or image button). these postback by sending their name and value in form fields collection.

-- bruce (sqlwork.com)

"Dan" <no********@nowhere.com> wrote in message news:#x*************@tk2msftngp13.phx.gbl...
the items do actually exist in the Request.Form collection...

but are ""
"vMike" <Mi************@gewarren.com.nospam> wrote in message news:bq**********@ngspool-d02.news.aol.com...
You should be able to add an eventhandler, but if you don't want to you can use Request.Form("__EVENTTARGET"). You must have a control on your form that renders the function __doPostBack(eventTarget, eventArgument) on your page. Many controls will put the function on your page. You could always put a dummy control like a linkbutton or something on your page to force the script to be rendered. Hope this helps.

"Dan" <no********@nowhere.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no references as to how to do it this way as I already know how.

I know this may be getting into advanced or unheard of territory.

I have some custom web user controls that are dynamically created at run time along with other controls. I can still add an event handler to these controls, but unfortunately the event handler wont fire until the controls are re-created on the postback, but I don't want the start-up code running on a post back, I need it to run in the event of the control that cuased the post back. This works fine for my other controls on the form that arn't generated, but will not for this user control, so I need an alternative.

I need some indication in my page_load (or init) event that tells me that our user control has initiated the postback and to then run start up code.

Are there any techniques out there that allow me to dig into the postback and discover what control or control type made the postback?

Another solution I could add a client side handler that could set the value of a checkbox but due to the complexity of the user control I am not going to do that, as a post back could be initiated by a multiple number of events on different controls within the user control.

Thats my question! Thanks..
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JollyK | last post by:
Hi friends, This is my question.... From the Page Load event (or Page Init event), I would need to find which event had occurred that caused a PostBack, for example was it a event fired from...
1
by: bill yeager | last post by:
I have a datagrid control within a datalist control. When I try and do a "Find" on the control, the object comes back with nothing and then my pgm crashes. I am 100% sure that my datagird inside...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
6
by: Angel | last post by:
I have a button, combo, and custom control that i created. When I click the button i want to set certain display properties of my custom control depending whats in the combo. I set those properties...
4
by: wardy | last post by:
Hi all, Looking for a bit of help with this one...I have a situation where I need to be able to determine the control that initiated a form's submit action in client-side Javascript. I am...
2
by: brad | last post by:
Group, I'm using Visual Studio 2003 to create an ASP.NET 1.1 project which contains nested server user controls in order to create a tree-like hierarchy. The tree is a sort of question and...
1
by: Sue | last post by:
Hello Is there an equivalent of a OnTextChangedEvent for a asp: label control in asp.Net 2.0. Every time the text of a label changes, I want the items in a listbox control cleared. TIA Sue..
4
by: PokerMan | last post by:
Hi I have a few controls on apage that cause a postback. But want to handle a postback differently depending on which one of these controls fired the postback. How do we do this? c#. Thanks
2
by: bbragan | last post by:
I am trying to determine which button on my page initiated the postback. I need to make this determination during the pageload event of the codebehind page. The environment is vb.net 2003 and .net...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.