By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,996 Members | 1,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,996 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
Shane,

You'll love how easy this is!

On your delete button just set it's "CausesValidation" 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*************@tk2msftngp13.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

P: n/a
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*****@aboutfortunate.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Shane,

You'll love how easy this is!

On your delete button just set it's "CausesValidation" 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*************@tk2msftngp13.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

P: n/a
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****************@TK2MSFTNGP12.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*****@aboutfortunate.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Shane,

You'll love how easy this is!

On your delete button just set it's "CausesValidation" 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*************@tk2msftngp13.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 discussion thread is closed

Replies have been disabled for this discussion.