Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2018, 06:48 PM
Authorized User
 
Join Date: Mar 2017
Posts: 55
Thanks: 12
Thanked 0 Times in 0 Posts
Default Chapter 14 - page 525-527 Validation Issue

After following all the steps in Chapter 14 - pages 525-527, I was able to upload images to the Photo Album / Pictures tables. However, when I attempt to DELETE an entry (using the delete button previously created for the ManagePhotoAlbum page) - I get validation messages on the Insert fields triggered. Even though I did not press Insert, but rather Delete. Because of these validation items being triggered, the ListView1_DeleteItem(int id) method never fires and therefore I cannot delete any items.

When I set the 'Causes Validation' property in the Delete button section from 'true' to 'false', I was then able to delete. But shouldn't that be independent of the Insert Validation?

Please assist. I am using VS Community 2017 on Windows 10 with SQL Sever 2012.

Daniel
 
Old March 30th, 2018, 07:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Daniel,

Looks like you missed the CausesValidation attribute on page 514:

Code:
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete"
Text="Delete" CausesValidation="False" />
With that attribute set to False, the Delete but no longer triggers a call to the validation routines.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
papadan (March 30th, 2018)
 
Old March 30th, 2018, 12:11 PM
Authorized User
 
Join Date: Mar 2017
Posts: 55
Thanks: 12
Thanked 0 Times in 0 Posts
Default

Thanks, I see that I missed that now.

What if I want the Delete button to fire off some validation of it's own? I assume I would have to do it in the C# (or VB) event handler, correct? The ListView1_DeleteItem(int id) event, correct?

Or is there a way to fire off separate validation (without touching the Insert validation controls) for the Delete button, without going into the event handler?
 
Old April 1st, 2018, 07:39 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can use ValidationGroup to separate one set of controls from another: https://msdn.microsoft.com/en-us/library/ms227424.aspx
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
papadan (April 1st, 2018)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue : Chapter 14 - Mailing List angelotheus BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 0 March 1st, 2017 11:47 PM
Chapter 14 Try It Out p. 525 File Upload TI2016 BOOK: Beginning ASP.NET 4.5.1 : in C# and VB 1 September 9th, 2016 03:09 AM
Security (Chapter 13 pages 526-527) stephen.lunt BOOK: Professional Access 2013 Programming 0 November 13th, 2014 09:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.