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

finding which button is pressed

Hi

I have a form with two butons

I know if the form is a postback but I can't
find anyway to tell which button was clicked,
on the form load event.

I have a feeling that this is obvious.

Any guidance appreciated

thanks

jc



Jan 24 '06 #1
5 1717
Earliest solution i can suggest is to query Request.Form("Button")

Best Regards
Jignesh Desai
www.dotnetjini.com

"Jonathan Crawford" <jc@jcrawford.co.uk> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi

I have a form with two butons

I know if the form is a postback but I can't
find anyway to tell which button was clicked,
on the form load event.

I have a feeling that this is obvious.

Any guidance appreciated

thanks

jc


Jan 24 '06 #2
JC,

Are you using asp.net 1.1 or 2.0? And are these buttons regular html buttons
or buttons set with runat="server"?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jignesh Desai" <ji***********@hotmail.com> wrote in message
news:um**************@TK2MSFTNGP15.phx.gbl...
Earliest solution i can suggest is to query Request.Form("Button")

Best Regards
Jignesh Desai
www.dotnetjini.com

"Jonathan Crawford" <jc@jcrawford.co.uk> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi

I have a form with two butons

I know if the form is a postback but I can't
find anyway to tell which button was clicked,
on the form load event.

I have a feeling that this is obvious.

Any guidance appreciated

thanks

jc



Jan 24 '06 #3
ASP.NET 1.1 and aspbuttons are server control buttons

thanks jc

--

"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
JC,

Are you using asp.net 1.1 or 2.0? And are these buttons regular html
buttons or buttons set with runat="server"?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jignesh Desai" <ji***********@hotmail.com> wrote in message
news:um**************@TK2MSFTNGP15.phx.gbl...
Earliest solution i can suggest is to query Request.Form("Button")

Best Regards
Jignesh Desai
www.dotnetjini.com

"Jonathan Crawford" <jc@jcrawford.co.uk> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi

I have a form with two butons

I know if the form is a postback but I can't
find anyway to tell which button was clicked,
on the form load event.

I have a feeling that this is obvious.

Any guidance appreciated

thanks

jc




Jan 24 '06 #4
Jonathan,

I just wanted to double check. In that case this will work:

'---Check if the sender is a button

If sender.GetType Is GetType(Button) Then

'---If it is a button check which one

Dim ButtonSent As Button = CType(sender, Button)

Dim ButtonName As String = ButtonSent.ID

End If
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jonathan Crawford" <jc@jcrawford.co.uk> wrote in message
news:Or*************@tk2msftngp13.phx.gbl...
ASP.NET 1.1 and aspbuttons are server control buttons

thanks jc

--

"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
in message news:%2****************@TK2MSFTNGP10.phx.gbl...
JC,

Are you using asp.net 1.1 or 2.0? And are these buttons regular html
buttons or buttons set with runat="server"?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jignesh Desai" <ji***********@hotmail.com> wrote in message
news:um**************@TK2MSFTNGP15.phx.gbl...
Earliest solution i can suggest is to query Request.Form("Button")

Best Regards
Jignesh Desai
www.dotnetjini.com

"Jonathan Crawford" <jc@jcrawford.co.uk> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi

I have a form with two butons

I know if the form is a postback but I can't
find anyway to tell which button was clicked,
on the form load event.

I have a feeling that this is obvious.

Any guidance appreciated

thanks

jc





Jan 24 '06 #5
You can always just compare the reference of "sender" with that of your
Button variables (assuming you have declared protected class-level
Button variables having the same names as the IDs of your Buttons):

[in C# - sorry, I'm not familiar enough with VB.NET to be 100% sure
about the code]

protected Button btnButton1;
protected Button btnButton2;
....
private void Button_ClickHandler(object sender, EventArgs e)
{
if(sender == this.btnButton1)
{
...
}
else if(sender == this.btnButton2)
{
...
}
}

(I believe in VB.NET, the conditional would be
If sender = Me.btnButton2 Then ...
)

Hope this helps...

Luke

Jan 24 '06 #6

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

Similar topics

1
by: robert | last post by:
hi! I want to have a custom button change appearance when pressed and then call a function and change back to its original appearance when released. here's what i have now, which works mostly....
2
by: jb | last post by:
Hello, I need to know which button was pressed in the submit , i tried reading the vaule of submit it the validateDate function but it returns 'undefined' value ; I do this in asp all the time, Not...
8
by: Syed Ali | last post by:
Hello, I have 1 HTML form with 4 submit buttons and 10 textfield entry areas. If submit button1 is pressed I need to make sure that all 10 textfield entries have been filled before submitting...
3
by: James McGivney | last post by:
I have a project in VS.NET using C# I have a series of buttons on an aspx page. When one of the buttons is pressed, a panel becomes visible and allows the user to enter and edit data. I want to...
18
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to...
7
by: Amadelle | last post by:
Hi all and thanks in advance, I am stuck! I can't figure out how to identify which button was clicked on my ASP.NET page in the PostBack event? So what I am trying to do is to is to have an if...
2
by: Krista Lemieux | last post by:
Hello, In my form I have a button, and the button_Click function (which gets called when the button is clicked). However the functionality that I have in the button_Click function, needs to be...
6
by: Jithu | last post by:
hi, I have a dropdownlist and a button in my web page. Both controls fire the page_load event on postback. I want to find out which control does the postback? I have a function in the...
19
by: darrel | last post by:
On my vb.net page, I have 4 sets of inputs + form buttons. example: Search: (GO) Zip: (GO) County: (GO) County: (GO) The problem is if I go to the page, type in a zip code, and hit...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.