473,405 Members | 2,167 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,405 software developers and data experts.

Knowing which control caused postback

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
Apr 13 '07 #1
4 1528
"PokerMan" <no****@pokercat.co.ukwrote in message
news:O9**************@TK2MSFTNGP02.phx.gbl...
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#.
Each control which generates the postback will fire its own postback event
i.e. the one for which it is wired up...

E.g. if you have two <asp:Buttoncontrols each with its own OnClick()
event, they will each fire their own OnClick() event on postback... Put
different code in each event as required...

Is that what you mean...?
Apr 13 '07 #2
The easiest way is to handle server-side events for the controls in separate
event handlers. If you need to know the postback source in the Page_Load
event, that fires before control events, you can check
Request.Form["__EVENTTARGET"] . It will work only if the postback was
initiated be a control other that a button.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"PokerMan" <no****@pokercat.co.ukwrote in message
news:O9**************@TK2MSFTNGP02.phx.gbl...
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


Apr 13 '07 #3
Usually all generated events have a parameter "ender"
like click of the button event
protected void btnDelete_OnClick(object sender, EventArgs e)

sender will point to the object that causes that event.

George.

"PokerMan" <no****@pokercat.co.ukwrote in message
news:O9**************@TK2MSFTNGP02.phx.gbl...
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

Apr 13 '07 #4
On Apr 13, 3:23 pm, "PokerMan" <nos...@pokercat.co.ukwrote:
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

Apr 13 '07 #5

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

Similar topics

2
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...
5
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...
1
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....
5
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
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...
3
by: Martin | last post by:
Hi, I have created a composite control that has a number of standard asp.net controls on it that can themselves cause postbacks. What i need to do in my composite control is to determine which...
4
by: dchillman | last post by:
string ctrlname = page.Request.Params.Get("__EVENTTARGET"); if (ctrlname != null && ctrlname != string.Empty) { return this.Page.FindControl(ctrlname); } I have a form on which I was trying...
2
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...
3
by: Mike Gleason jr Couturier | last post by:
I know the ASP.NET page cycle: The Clicked event is called after the Page_Load... Don't ask why but I need to in the Page_Load if a particular control has caused the postback... Any ideas? ...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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...
0
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,...
0
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...

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.