473,625 Members | 2,600 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple asp:buttons on one form but ONLY one should submit?

Sorry for the length of this post.

I have created a rather complex form which has a header/line item (parent
and child records) structure. It's for an intranet. A screenshot can be
seen here: http://www.drpt.virginia.gov/temp1.gif All the fields on this
form have validation controls on them so they can not submit the form unless
all fields are completed and some fall within a specified numeric range.

When the form first is loaded, there are two buttons as shown in the link
above that are disabled by default. They become enabled once the form is
submitted.

Here's the basic concept. The user fills out the form and clicks Save Data.
The form is using ViewState so when the form is submitted (Save Data), the
page posts to itself and the data "sticks" in the fields. The Save Data
button fires a sub routine which writes the data in the top section of the
form to one table and the "line item" section to another table. When the
data is successfully saved as shown in
http://www.drpt.virginia.gov/temp2.gif, a confirmation label is shown on the
page and a DataGrid displays the new line item. The user can then add a
second, third or however many line items by simply filling in the fields
(and even changing the header information if needed) and clicking Save Data
each time. My sub successfully works and each time the page "loads", the
DataGrid gets a new row (image only shows one). So far, so good.

The thought behind this structure is that the user needs to able to enter in
multiple line items as needed, so here I'm letting them add them one at a
time instead hard coding X number of blank line items ...X number of rows of
form fields (the validation for that would be a nightmare).

All works fine. Once the SaveData sub is fired, I set a variable in
ViewState and enable the two additional buttons at the button and change my
INSERT statement to UPDATE statement for the header data. One of the newly
enabled buttons is a "Delete" button. I wanted to allow the user to Delete
all the records and start over with a fresh form.

Here's the problem (finally): My delete sub works just fine but by clicking
the "Delete" button causes the form to post and all of the field validators
are triggered. Instead of deleting the data and refreshing the page as my
sub should do, I'm prompted to provide data in all the required fields! In
short, my form thinks my delete button is a submit button instead of just a
plain button.

Is there anyway to work around this? I see that you cannot define exactly
what TYPE of button it is using asp:button such as type="button" or
type="submit". So how can I use a button to call my DeleteRecords sub
without being pestered by the form validation controls?

TIA!!!

-Shane
Nov 18 '05 #1
3 2558
Shane,

You'll love how easy this is!

On your delete button just set it's "CausesValidati on" property to false.
Then it won't trigger the validators.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"D. Shane Fowlkes" <sh********** @h-o-t-m-a-i-l.com> wrote in message
news:Oj******** *****@tk2msftng p13.phx.gbl...
Sorry for the length of this post.

I have created a rather complex form which has a header/line item (parent
and child records) structure. It's for an intranet. A screenshot can be
seen here: http://www.drpt.virginia.gov/temp1.gif All the fields on this
form have validation controls on them so they can not submit the form unless all fields are completed and some fall within a specified numeric range.

When the form first is loaded, there are two buttons as shown in the link
above that are disabled by default. They become enabled once the form is
submitted.

Here's the basic concept. The user fills out the form and clicks Save Data. The form is using ViewState so when the form is submitted (Save Data), the
page posts to itself and the data "sticks" in the fields. The Save Data
button fires a sub routine which writes the data in the top section of the
form to one table and the "line item" section to another table. When the
data is successfully saved as shown in
http://www.drpt.virginia.gov/temp2.gif, a confirmation label is shown on the page and a DataGrid displays the new line item. The user can then add a
second, third or however many line items by simply filling in the fields
(and even changing the header information if needed) and clicking Save Data each time. My sub successfully works and each time the page "loads", the
DataGrid gets a new row (image only shows one). So far, so good.

The thought behind this structure is that the user needs to able to enter in multiple line items as needed, so here I'm letting them add them one at a
time instead hard coding X number of blank line items ...X number of rows of form fields (the validation for that would be a nightmare).

All works fine. Once the SaveData sub is fired, I set a variable in
ViewState and enable the two additional buttons at the button and change my INSERT statement to UPDATE statement for the header data. One of the newly enabled buttons is a "Delete" button. I wanted to allow the user to Delete all the records and start over with a fresh form.

Here's the problem (finally): My delete sub works just fine but by clicking the "Delete" button causes the form to post and all of the field validators are triggered. Instead of deleting the data and refreshing the page as my
sub should do, I'm prompted to provide data in all the required fields! In short, my form thinks my delete button is a submit button instead of just a plain button.

Is there anyway to work around this? I see that you cannot define exactly
what TYPE of button it is using asp:button such as type="button" or
type="submit". So how can I use a button to call my DeleteRecords sub
without being pestered by the form validation controls?

TIA!!!

-Shane

Nov 18 '05 #2
Yeah! Thanks! Boy that was easy.

I seem to have trouble remembering all the attributes, namespaces, etc for
all this .NET stuff. Is there a good book which documents and diagrams all
this stuff out? I have ASP.NET Unleashed by SAMS but I'd like to get my
hands on some good reference "charts" and diagrams which show ALL the
attributes for ALL the web controls, etc....

=)
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Shane,

You'll love how easy this is!

On your delete button just set it's "CausesValidati on" property to false.
Then it won't trigger the validators.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"D. Shane Fowlkes" <sh********** @h-o-t-m-a-i-l.com> wrote in message
news:Oj******** *****@tk2msftng p13.phx.gbl...
Sorry for the length of this post.

I have created a rather complex form which has a header/line item (parent and child records) structure. It's for an intranet. A screenshot can be seen here: http://www.drpt.virginia.gov/temp1.gif All the fields on this form have validation controls on them so they can not submit the form unless
all fields are completed and some fall within a specified numeric range.

When the form first is loaded, there are two buttons as shown in the link above that are disabled by default. They become enabled once the form is submitted.

Here's the basic concept. The user fills out the form and clicks Save

Data.
The form is using ViewState so when the form is submitted (Save Data), the page posts to itself and the data "sticks" in the fields. The Save Data
button fires a sub routine which writes the data in the top section of the form to one table and the "line item" section to another table. When the data is successfully saved as shown in
http://www.drpt.virginia.gov/temp2.gif, a confirmation label is shown on

the
page and a DataGrid displays the new line item. The user can then add a
second, third or however many line items by simply filling in the fields
(and even changing the header information if needed) and clicking Save

Data
each time. My sub successfully works and each time the page "loads", the DataGrid gets a new row (image only shows one). So far, so good.

The thought behind this structure is that the user needs to able to enter in
multiple line items as needed, so here I'm letting them add them one at
a time instead hard coding X number of blank line items ...X number of rows of
form fields (the validation for that would be a nightmare).

All works fine. Once the SaveData sub is fired, I set a variable in
ViewState and enable the two additional buttons at the button and change my
INSERT statement to UPDATE statement for the header data. One of the

newly
enabled buttons is a "Delete" button. I wanted to allow the user to

Delete
all the records and start over with a fresh form.

Here's the problem (finally): My delete sub works just fine but by

clicking
the "Delete" button causes the form to post and all of the field

validators
are triggered. Instead of deleting the data and refreshing the page as

my sub should do, I'm prompted to provide data in all the required fields!

In
short, my form thinks my delete button is a submit button instead of just a
plain button.

Is there anyway to work around this? I see that you cannot define

exactly what TYPE of button it is using asp:button such as type="button" or
type="submit". So how can I use a button to call my DeleteRecords sub
without being pestered by the form validation controls?

TIA!!!

-Shane


Nov 18 '05 #3
Shane,

I don't have any books to recommend. I have some of the same ones you
mentioned but I don't have any reference books. I just find myself using
google and the forums for most of this type of stuff.

If you find a good one please let me know!

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"D. Shane Fowlkes" <sh********** @h-o-t-m-a-i-l.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Yeah! Thanks! Boy that was easy.

I seem to have trouble remembering all the attributes, namespaces, etc for
all this .NET stuff. Is there a good book which documents and diagrams all
this stuff out? I have ASP.NET Unleashed by SAMS but I'd like to get my
hands on some good reference "charts" and diagrams which show ALL the
attributes for ALL the web controls, etc....

=)
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Shane,

You'll love how easy this is!

On your delete button just set it's "CausesValidati on" property to false.
Then it won't trigger the validators.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"D. Shane Fowlkes" <sh********** @h-o-t-m-a-i-l.com> wrote in message
news:Oj******** *****@tk2msftng p13.phx.gbl...
Sorry for the length of this post.

I have created a rather complex form which has a header/line item (parent and child records) structure. It's for an intranet. A screenshot can be seen here: http://www.drpt.virginia.gov/temp1.gif All the fields on this form have validation controls on them so they can not submit the form unless
all fields are completed and some fall within a specified numeric range.
When the form first is loaded, there are two buttons as shown in the link above that are disabled by default. They become enabled once the form is submitted.

Here's the basic concept. The user fills out the form and clicks Save

Data.
The form is using ViewState so when the form is submitted (Save Data), the page posts to itself and the data "sticks" in the fields. The Save Data button fires a sub routine which writes the data in the top section of the form to one table and the "line item" section to another table. When the data is successfully saved as shown in
http://www.drpt.virginia.gov/temp2.gif, a confirmation label is shown on the
page and a DataGrid displays the new line item. The user can then add
a second, third or however many line items by simply filling in the fields (and even changing the header information if needed) and clicking Save

Data
each time. My sub successfully works and each time the page "loads", the DataGrid gets a new row (image only shows one). So far, so good.

The thought behind this structure is that the user needs to able to enter
in
multiple line items as needed, so here I'm letting them add them one

at a time instead hard coding X number of blank line items ...X number of rows
of
form fields (the validation for that would be a nightmare).

All works fine. Once the SaveData sub is fired, I set a variable in
ViewState and enable the two additional buttons at the button and
change my
INSERT statement to UPDATE statement for the header data. One of the

newly
enabled buttons is a "Delete" button. I wanted to allow the user to

Delete
all the records and start over with a fresh form.

Here's the problem (finally): My delete sub works just fine but by

clicking
the "Delete" button causes the form to post and all of the field

validators
are triggered. Instead of deleting the data and refreshing the page
as my sub should do, I'm prompted to provide data in all the required
fields! In
short, my form thinks my delete button is a submit button instead of

just
a
plain button.

Is there anyway to work around this? I see that you cannot define

exactly what TYPE of button it is using asp:button such as type="button" or
type="submit". So how can I use a button to call my DeleteRecords sub
without being pestered by the form validation controls?

TIA!!!

-Shane



Nov 18 '05 #4

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

Similar topics

5
4420
by: Matt | last post by:
How can I implement multiple buttons for a form like - submit, cancel, logout etc. Thanks. Matt
2
2099
by: Matt | last post by:
The ASP page has multiple buttons, and when the user clicks different buttons, it will submit the form data to different URLs. My first approach was to use BUTTON type, and triggers javascript function to submit the form data. However, it didn't work properly and I changed to use SUBMIT type. <INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search Page" onClick="action1()">
2
2003
by: iam247 | last post by:
Hi I have an ASP form which only includes an option list. The list is dynamically created but includes a default value, which is an instruction "Select a group". The code is shown at bottom. I want to ensure the user does not submit the form with the default value selected.
2
3248
by: D | last post by:
Most of my web forms have multiple buttons (Proceed, Back, link buttons for various screens, etc.) It looks like, say a required field validator for example, gives me an error message no matter which button is pushed. Well, the user simply wants to navigate to a different screen without filling out the form. So is there a way to tie validation controls to specific buttons?
1
1845
by: Sarmatia | last post by:
I had a page working. The user moves data around the page - to and from different ListBoxes and could save the changes with a click of a button. Sounds easy, but *that's* a whole other nightmare. Nevertheless, it was working. The Submit button was an asp:button with an OnClick server-side method. Easy-cheesy. Enter in-house standards. I need to add an access key and underline the letter on the button
9
4265
by: mosscliffe | last post by:
I am struggling to find a python example of the scenario - I have. I have a python script, which generates a page with a search button (actually an input field). The data from the above submissions is interrogated and the same script produces a new search option and the a page of results from the previous search request. - as done by Google's Main search page. The user then has the option of a new search or navigating to a
0
2173
by: jianxin9 | last post by:
Hi everyone, I don't have a lot of experience with ASP and I was hoping someone could help me. I want to use our ASP form along with some javascript code to create a form where our patrons can select which department they will send the form to (we are trying to consolidate forms). This is what I have so far, but when I test the form, I keep getting this error message: Mailing Failed... Error is: FromAddress Property cannot be blank. You...
1
3578
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1- <SCRIPT TYPE="text/javascript"> function popupform(myform, windowname)
0
1237
by: fperri | last post by:
Hi, I'm doing my first site in ASP.net. I have a form that has two list boxes where they can select a value in one and click a button to select and it moves it to the other listbox. I got this to work ok but once I finished the form and added my required field validators when the select button is clicked I get an error saying; Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in...
0
8251
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8494
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7178
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6115
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4085
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.