473,625 Members | 2,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determining control that caused a postback

string ctrlname = page.Request.Pa rams.Get("__EVE NTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
{
return this.Page.FindC ontrol(ctrlname );
}
I have a form on which I was trying to determine which user-action caused a
postback. In various places I found the code above that works for most
controls.

The problem I have been having is with radiobutton list control. A value
for "ctrlname" will be found, but this.Page.FindC ontrol(ctrlname ) returns a
null value. The problem appears to be related to the value for ctrlname that
is returned. Its construction appears to be related to the type of control.
Dropdown list controls seem to have the format
pagename:contro lname
while my radiobutton list control has the format
pagename_contro lname_n, where n is 1, 2, 3, ....

For my needs, I wrote code to extract the real control name which is then
passed to the Page.FindContro l method.

My question has to do with the values returned by

page.Request.Pa rams.Get("__EVE NTTARGET");

Are there rules for how it constructs the value it returns for each type of
control, and if so, where can I find them?

Thanks
--
dchillman
Nov 19 '05 #1
4 2212
Why do you need to figure this out?

Handle the events of the various controls, the click for the buttons,
selectedindexch anged for the dropdowns, etc.

"dchillman" <dc*******@disc ussions.microso ft.com> wrote in message
news:F5******** *************** ***********@mic rosoft.com...
string ctrlname = page.Request.Pa rams.Get("__EVE NTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
{
return this.Page.FindC ontrol(ctrlname );
}
I have a form on which I was trying to determine which user-action caused
a
postback. In various places I found the code above that works for most
controls.

The problem I have been having is with radiobutton list control. A value
for "ctrlname" will be found, but this.Page.FindC ontrol(ctrlname ) returns
a
null value. The problem appears to be related to the value for ctrlname
that
is returned. Its construction appears to be related to the type of
control.
Dropdown list controls seem to have the format
pagename:contro lname
while my radiobutton list control has the format
pagename_contro lname_n, where n is 1, 2, 3, ....

For my needs, I wrote code to extract the real control name which is then
passed to the Page.FindContro l method.

My question has to do with the values returned by

page.Request.Pa rams.Get("__EVE NTTARGET");

Are there rules for how it constructs the value it returns for each type
of
control, and if so, where can I find them?

Thanks
--
dchillman

Nov 19 '05 #2
new to the asp.net world, so pardon my ignorance. I have a radiobutton list
control, a couple dropdown list controls, and a grid control on the form.
When the user selects items from the list controls, the grid would update
with the proper data. Originally I was handling loading the proper data into
the controls during the postback and wanted to know which one caused the
post-back, so I could take different action during the post-back. I think I
just started down this path and just didn't see the simpler solution. Thanks
for pointing me back in the right direction.

For curiosity sake, I still am wondering if there are rules to the value
returned by

page.Request.Pa rams.Get("__EVE NTTARGET");
thanks
--
dchillman
"Marina" wrote:
Why do you need to figure this out?

Handle the events of the various controls, the click for the buttons,
selectedindexch anged for the dropdowns, etc.

"dchillman" <dc*******@disc ussions.microso ft.com> wrote in message
news:F5******** *************** ***********@mic rosoft.com...
string ctrlname = page.Request.Pa rams.Get("__EVE NTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
{
return this.Page.FindC ontrol(ctrlname );
}
I have a form on which I was trying to determine which user-action caused
a
postback. In various places I found the code above that works for most
controls.

The problem I have been having is with radiobutton list control. A value
for "ctrlname" will be found, but this.Page.FindC ontrol(ctrlname ) returns
a
null value. The problem appears to be related to the value for ctrlname
that
is returned. Its construction appears to be related to the type of
control.
Dropdown list controls seem to have the format
pagename:contro lname
while my radiobutton list control has the format
pagename_contro lname_n, where n is 1, 2, 3, ....

For my needs, I wrote code to extract the real control name which is then
passed to the Page.FindContro l method.

My question has to do with the values returned by

page.Request.Pa rams.Get("__EVE NTTARGET");

Are there rules for how it constructs the value it returns for each type
of
control, and if so, where can I find them?

Thanks
--
dchillman


Nov 19 '05 #3
Request.Params. Get("__EVENTTAR GET") returns the name that FindControl
expects. but you need to recreate the controls first for FindContol to work.

note: the button and imagebutton controls do not use _EVENTTARGET

-- bruce (sqlwork.com)

"dchillman" <dc*******@disc ussions.microso ft.com> wrote in message
news:F5******** *************** ***********@mic rosoft.com...
string ctrlname = page.Request.Pa rams.Get("__EVE NTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
{
return this.Page.FindC ontrol(ctrlname );
}
I have a form on which I was trying to determine which user-action caused
a
postback. In various places I found the code above that works for most
controls.

The problem I have been having is with radiobutton list control. A value
for "ctrlname" will be found, but this.Page.FindC ontrol(ctrlname ) returns
a
null value. The problem appears to be related to the value for ctrlname
that
is returned. Its construction appears to be related to the type of
control.
Dropdown list controls seem to have the format
pagename:contro lname
while my radiobutton list control has the format
pagename_contro lname_n, where n is 1, 2, 3, ....

For my needs, I wrote code to extract the real control name which is then
passed to the Page.FindContro l method.

My question has to do with the values returned by

page.Request.Pa rams.Get("__EVE NTTARGET");

Are there rules for how it constructs the value it returns for each type
of
control, and if so, where can I find them?

Thanks
--
dchillman

Nov 19 '05 #4
Can you elaborate on what you mean by "recreate the controls first for
FindControl to work"?

thanks
--
dchillman
"Bruce Barker" wrote:
Request.Params. Get("__EVENTTAR GET") returns the name that FindControl
expects. but you need to recreate the controls first for FindContol to work.

note: the button and imagebutton controls do not use _EVENTTARGET

-- bruce (sqlwork.com)

"dchillman" <dc*******@disc ussions.microso ft.com> wrote in message
news:F5******** *************** ***********@mic rosoft.com...
string ctrlname = page.Request.Pa rams.Get("__EVE NTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
{
return this.Page.FindC ontrol(ctrlname );
}
I have a form on which I was trying to determine which user-action caused
a
postback. In various places I found the code above that works for most
controls.

The problem I have been having is with radiobutton list control. A value
for "ctrlname" will be found, but this.Page.FindC ontrol(ctrlname ) returns
a
null value. The problem appears to be related to the value for ctrlname
that
is returned. Its construction appears to be related to the type of
control.
Dropdown list controls seem to have the format
pagename:contro lname
while my radiobutton list control has the format
pagename_contro lname_n, where n is 1, 2, 3, ....

For my needs, I wrote code to extract the real control name which is then
passed to the Page.FindContro l method.

My question has to do with the values returned by

page.Request.Pa rams.Get("__EVE NTTARGET");

Are there rules for how it constructs the value it returns for each type
of
control, and if so, where can I find them?

Thanks
--
dchillman


Nov 19 '05 #5

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

Similar topics

2
1647
by: Jeff Voigt | last post by:
Is there any way to dynamically get the name of the control that caused the postback? Since SmartNav is not working for me I'm trying to implement a way to scroll to the control that caused the post back so the user does not have to scroll all the time. I got the script working great and everything else, but I want to be able to tell the name of the control that posted back. That way we don't have to hard code much at all. This is...
3
1936
by: Wayne | last post by:
I am wondering if it is at all possible to ascertain what cause the PostBack event to occur? Currently I have a DropDownList and 2 Radio buttons that cause a PB (this may change to 2 Buttons if I am unable to determine the calling control) whenever their status is changed. Is it possible to obtain the calling control/method or is this outside the scope?
5
4797
by: Dan | last post by:
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...
1
5755
by: Roz Lee | last post by:
I have a page with two textboxes and two buttons which post back to the server. I want to detect which button has been clicked for testing purposes preferably clientside, but otherwise serverside. However, when I examine Page.Request.Form("__EventTarget") in my aspx.vb Page Load sub , Page.Request.Form("__EventTarget") is nothing. If I view source, the DoPostback function is not visible, nor are the hidden EventTarget and EventArgument...
4
2151
by: RTM | last post by:
Can anyone help me with the following issue? I've seen some similar questions here, but none relating to a textbox control.... I have a form with several controls, one of them being a textbox control with AutoPostBack set to true. I need to fire a method ONLY when the form has posted back due to a button click (no problem here), or from the user typing text in the text box and hitting enter. I can't call this method from any postback,...
5
1486
by: vbMental | last post by:
Is there anyway to find out which control fired the postback in server-side code? Like in windows programming "Form.ActiveControl" ?
5
5038
by: Joey G | last post by:
How do I get the name or identify the control that caused the page postback. I need the information during page init. Reason why, because I need to tell usercontrol_1 that usercontrol_2 button was clicked and therefore need usercontrol_2 public properties to be passed to usercontrol_1 public properties in the case of the event. thanks
5
2678
by: Nathan Sokalski | last post by:
I have a DataList that I was having trouble getting the events for. After a bit of help, I realized that I needed to put the databinding inside an If Not IsPostBack() condition. Although this fixed the individual problem, it caused problems in other areas. This is because the DataSource that I use for my databinding changes and must be "rebound". Because there is only one situation where I need the If Not IsPostBack() condition, I think it...
2
2180
by: sunilthk | last post by:
Hi All, I have a question. If javascript is disabled how asp.net determines which control has caused the post back. As we know that when we clicks on the button the buttons name goes with posted data, so asp.net can detrmine which btn caused the post back. In case of dropdown lists(if auto post back is true) _doPostback javascript function is called which assigns the name of the control in _EVENTTARGET hidden variable, by this ASP.NET...
0
8253
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
8692
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...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8354
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
8497
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...
1
6116
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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();...
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
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.