G
Guest
Is there anyway to find out which control fired the postback in server-side
code?
Like in windows programming "Form.ActiveControl" ?
code?
Like in windows programming "Form.ActiveControl" ?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Karl Seguin said:You can peak under the covers and take a look at
Request.Form["__EVENTTARGET"]
which will give you the UniqueId of the control which cause the event to
fire. If the contro was a WebControls.Button then __EVENTTARGET will
unfortunetly be blank, but the button's unique ID will be in the
Request.Form collection...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
vbMental said:Is there anyway to find out which control fired the postback in server-side
code?
Like in windows programming "Form.ActiveControl" ?
vbMental said:Thanks, and I figured something like that but I wanted a standard .NET way to
do it.
Karl Seguin said:You can peak under the covers and take a look at
Request.Form["__EVENTTARGET"]
which will give you the UniqueId of the control which cause the event to
fire. If the contro was a WebControls.Button then __EVENTTARGET will
unfortunetly be blank, but the button's unique ID will be in the
Request.Form collection...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
vbMental said:Is there anyway to find out which control fired the postback in server-side
code?
Like in windows programming "Form.ActiveControl" ?
Saravana said:If postback happen, it will fire corresponding post back event in the server
side. That post event will have sender as one of its parameter, with which
you can identify which control caused the postback.
But if you want it to find it in Page_Load, only option is
Request.Form["__EVENTTARGET"]. This method will only work if your control
has autopostback property set to true
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
vbMental said:Thanks, and I figured something like that but I wanted a standard .NET way to
do it.
Karl Seguin said:You can peak under the covers and take a look at
Request.Form["__EVENTTARGET"]
which will give you the UniqueId of the control which cause the event to
fire. If the contro was a WebControls.Button then __EVENTTARGET will
unfortunetly be blank, but the button's unique ID will be in the
Request.Form collection...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
Is there anyway to find out which control fired the postback in
server-side
code?
Like in windows programming "Form.ActiveControl" ?
vbMental said:I understand all that but wouldnt it be nice to just have a property of the
page called Postback control that would be the control that caused the
postback. It's in the __EventTarget form element anyway.
Saravana said:If postback happen, it will fire corresponding post back event in the server
side. That post event will have sender as one of its parameter, with which
you can identify which control caused the postback.
But if you want it to find it in Page_Load, only option is
Request.Form["__EVENTTARGET"]. This method will only work if your control
has autopostback property set to true
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
wayvbMental said:Thanks, and I figured something like that but I wanted a standard .NET
todo it.
:
You can peak under the covers and take a look at
Request.Form["__EVENTTARGET"]
which will give you the UniqueId of the control which cause the event to
fire. If the contro was a WebControls.Button then __EVENTTARGET will
unfortunetly be blank, but the button's unique ID will be in the
Request.Form collection...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
Is there anyway to find out which control fired the postback in
server-side
code?
Like in windows programming "Form.ActiveControl" ?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.