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

detect submit button with httprequest?

Hi all,

I am using .NET 1.1. I have a form with a cancel button, something like
this:

<form method="post"....>
<input type="submit" value="Submit">
<input type="submit" value="Cancel" id="btnCancel">

</form>
In the code behind, I am trying to use the Request object to see if the
cancel button was pushed (I have another button on the page also). I have
tried using:

Request["btnCancel"]
Request.Form["btnCancel"]
Request.Params["btnCancel"]

They all return null or empty string. I also tried Request["Cancel"] with
same results. These are in the page load method.

So, what is the best way to check to see which button was pushed?

Thanks in advance.
Jun 27 '08 #1
3 2479
"Daniel" <dh*****@gmail.com.nospamwrote in message
news:rJ********************@newsfe22.lga...
I am using .NET 1.1. I have a form with a cancel button, something like
this:

<form method="post"....>
<input type="submit" value="Submit">
<input type="submit" value="Cancel" id="btnCancel">

</form>

In the code behind, I am trying to use the Request object to see if the
cancel button was pushed (I have another button on the page also). I have
tried using:

Request["btnCancel"]
Request.Form["btnCancel"]
Request.Params["btnCancel"]

They all return null or empty string. I also tried Request["Cancel"] with
same results. These are in the page load method.

So, what is the best way to check to see which button was pushed?
I'm not quite sure what you're trying to do exactly, but this isn't the way
ASP.NET was designed to work at all...

One of the fundamental design goals of ASP.NET was precisely to eliminate
what you're seeing with the concept of the postback, e.g.

<form id="MyForm" runat="server">
<asp:Button ID="MySubmitButton" runat="server" Text="Submit"
OnClick="MySubmitButton_Click" />
<asp:Button ID="MyCancelButton" runat="server" Text="Cancel"
OnClick="MyCancelButton_Click" />
</form>

This means that you don't need to try to work out which button was pressed,
because when the Submit button is pressed MySubmitButton_Click() will run
and when the Cancel button is pressed MyCancelButton_Click() will run...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Daniel" <dh*****@gmail.com.nospamwrote in message
news:rJ********************@newsfe22.lga...
>I am using .NET 1.1. I have a form with a cancel button, something like
this:

<form method="post"....>
<input type="submit" value="Submit">
<input type="submit" value="Cancel" id="btnCancel">

</form>

In the code behind, I am trying to use the Request object to see if the
cancel button was pushed (I have another button on the page also). I have
tried using:

Request["btnCancel"]
Request.Form["btnCancel"]
Request.Params["btnCancel"]

They all return null or empty string. I also tried Request["Cancel"] with
same results. These are in the page load method.

So, what is the best way to check to see which button was pushed?

I'm not quite sure what you're trying to do exactly, but this isn't the
way ASP.NET was designed to work at all...

One of the fundamental design goals of ASP.NET was precisely to eliminate
what you're seeing with the concept of the postback, e.g.

<form id="MyForm" runat="server">
<asp:Button ID="MySubmitButton" runat="server" Text="Submit"
OnClick="MySubmitButton_Click" />
<asp:Button ID="MyCancelButton" runat="server" Text="Cancel"
OnClick="MyCancelButton_Click" />
</form>

This means that you don't need to try to work out which button was
pressed, because when the Submit button is pressed MySubmitButton_Click()
will run and when the Cancel button is pressed MyCancelButton_Click() will
run...
--
I am trying to get more familiar with the .NET way to doing things. What I
was suggesting is more Java like.

Thanks, I appreciate it!

Jun 27 '08 #3
"Daniel" <dh*****@gmail.com.nospamwrote in message
news:nN*******************@newsfe22.lga...
>I'm not quite sure what you're trying to do exactly, but this isn't the
way ASP.NET was designed to work at all...

I am trying to get more familiar with the .NET way to doing things. What I
was suggesting is more Java like.
ASP.NET bears very little (if any) resemblance to Java... Trying to learn
ASP.NET with a Java mindset really isn't going to get you very far, IMO...

Please don't take this as a patronising suggestion, but I strongly suggest
you get a copy of this:
http://www.amazon.com/ASP-NET-3-5-Du...1989693&sr=8-1

and work your way through it...

You'll probably find the learning curve quite steep at first, but that's
more due to the .NET Framework than to ASP.NET itself...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4

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

Similar topics

3
by: arpita | last post by:
hi all... is there a way to call a backend application on the onclick event of a submit button?.... thank you....
15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
12
by: |-|erc | last post by:
when a user clicks back to get to my site, I want it to run a javascript function. can you detect when the FORWARD button is greyed out? Herc -- I call3d this fugly and I'm proud...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
8
by: BJ | last post by:
Problem: How can I code up a client side process to detect if the network is available? Synopsis: I am writing ASP.NET input forms for a Panasonic Tuff book. The users will be walking around...
0
by: paulsanna | last post by:
Hi there, I have 2 buttons on the source page that would submit the form to the target. The target page page would do something different with the results based on which button was clicked. I am...
10
by: sliffy | last post by:
Hi all, While I understand there is no stop button handler, I do desire a way to know if a form submission was aborted. When I submit my page, I lock down all of the controls so no further...
5
by: pamela fluente | last post by:
I have placed a button on a page to open a pdf stored on another site. When the user clicks on the button I do a Redirect to the pdf URL .... and this seems to work fine. Question: is this...
5
by: =?Utf-8?B?S3VtYXIuQS5QLlA=?= | last post by:
Kumar.A.P.P Software Engineer, Infosys Technologies Limited. http://techaid.wordpress.com/
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
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
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,...
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
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,...
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.