469,645 Members | 1,941 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Postback control?

Is there anyway to find out which control fired the postback in server-side
code?
Like in windows programming "Form.ActiveControl" ?
Nov 18 '05 #1
5 1375
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" <vb******@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
Is there anyway to find out which control fired the postback in server-side code?
Like in windows programming "Form.ActiveControl" ?

Nov 18 '05 #2
Thanks, and I figured something like that but I wanted a standard .NET way to
do it.

"Karl Seguin" wrote:
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" <vb******@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
Is there anyway to find out which control fired the postback in

server-side
code?
Like in windows programming "Form.ActiveControl" ?


Nov 18 '05 #3
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" <vb******@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
Thanks, and I figured something like that but I wanted a standard .NET way to do it.

"Karl Seguin" wrote:
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" <vb******@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
Is there anyway to find out which control fired the postback in

server-side
code?
Like in windows programming "Form.ActiveControl" ?


Nov 18 '05 #4
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" wrote:
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" <vb******@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
Thanks, and I figured something like that but I wanted a standard .NET way

to
do it.

"Karl Seguin" wrote:
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" <vb******@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
> Is there anyway to find out which control fired the postback in
server-side
> code?
> Like in windows programming "Form.ActiveControl" ?


Nov 18 '05 #5
It would be, but it's possible the control doesn't exist yet. You get into
complexe page event issues...but yet, it really really would be nice..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"vbMental" <vb******@discussions.microsoft.com> wrote in message
news:56**********************************@microsof t.com...
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" wrote:
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" <vb******@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
Thanks, and I figured something like that but I wanted a standard .NET way
to
do it.

"Karl Seguin" wrote:

> 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" <vb******@discussions.microsoft.com> wrote in message
> news:94**********************************@microsof t.com...
> > Is there anyway to find out which control fired the postback in
> server-side
> > code?
> > Like in windows programming "Form.ActiveControl" ?
>
>
>


Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Matthew Louden | last post: by
9 posts views Thread by Robert Galvin | last post: by
10 posts views Thread by Krista Lemieux | last post: by
2 posts views Thread by Wizzard | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.