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 August 29th, 2016, 12:59 PM
Authorized User
 
Join Date: Feb 2016
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 9 Field Validator

In order for this first "try it out" to work I needed to add the line
<add tagPrefix="Wrox" tagName="ContactForm" src="~/Controls/ContactForm.ascx " />
to the web.config file. I do not see this discussed elsewhere; luckily I noticed the controls list in web config while editing it for the add key task, or I could have been chasing my tail for a bit getting the "ContactForm" control "registered". Did I miss something that would let the control work without this step, or is the fix so trivial that it did not make errata/discussion threads?
 
Old August 29th, 2016, 03:21 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

This is discussed extensively in Chapter 8 where the control is created. It's first registered directly on a page. Then later on the control is registered in the web.config so you don't have to do it on a page by page basis.

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!
 
Old August 29th, 2016, 06:13 PM
Authorized User
 
Join Date: Feb 2016
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Control tag added in chapter 8 indeed

Understood and Thank You for the quick reply! I had the banners tag in config.web from chapter 8, but got errors in chapter 9 as I had not added the ContactForm tag to webconfig; that task does not seem to be directly specified. I may have missed it, but checked back to see. I am going through the book task by task, and have not added or "spliced" any files since starting from blank in chapter 1. I remembered the need for control tag(s) while troubleshooting the errors generated due to the absence (of the Contact Form tag in config.web), but the task of adding the contact form might want to get added to the chapter 9 tasks in the spirit of adding things in an "enlightened" step by step manner:-). Again, I may have missed it in working through the book, as any other errors I have found thus far have been my own typos or other brain fade..

Thank You again for the quick reply!

Scott Lee
Snohomish, Washington
USA
 
Old August 31st, 2016, 03:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Oh, my bad. It's been a while since I wrote the book so when I read your post I thought the contact form control gets added in chapter 8, but I see now that it is the Banner control and that the contact form is added in chapter 9.

It wouldn't have been necessary to add the registration to the web.config though. Here's the relevant piece from Chapter 9 that describes how this is supposed to work (from Step 9 on page 304):

Quote:
Visual Studio remembers the last custom prefix you used and reuses that when dragging the user control onto the page. Depending on how you previously configured the Banner user control in Web.config, your Wrox: prefix may be different and will be something like uc1. That doesn’t matter for this exercise. Also note, when you drag the control in Design View, its ID is ContactForm1. For this exercise, the actual ID doesn’t matter, but beware of the difference when working with the control ID later in this chapter.
So what should have happened is Visual Studio adding the control declaration to the page you dragged the control into. It would either have used UC1 or Wrox but the control and its registration should have used the same name.

Does this help?

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!
 
Old August 31st, 2016, 10:58 AM
Authorized User
 
Join Date: Feb 2016
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 9 p 304-304 Field Validator Continued

I looked into this, and I do indeed have the exact highlited Wrox:ContentForm statement in Contact.aspx, (contact.aspx file content follows..)

<%@ Page Title="Contact Us" Language="C#" MasterPageFile="~/MasterPages/Frontend.master"
AutoEventWireup="true" CodeFile="Contact.aspx.cs" Inherits="About_Contact" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<Wrox:ContactForm ID="ContactForm" runat="server" />
</asp:Content>
..

but I still need the XML "add tagPrefix" statement for tagName "ContactForm"
<add tagPrefix="Wrox" tagName="ContactForm" src="~/Controls/ContactForm.ascx " /> in the web.config XML. I am running VS 2015 Community. Did I inadvertently stumble into a hack that worked, or is this possibly a "belts and suspenders" (sorry for the colloquial americanism there) control state that is needed for web forms to "compile" properly in this later VS version?

The Contact.aspx page expects HTML and did not like an attempt to place the XML statement from web config there :-) when I tried it..

scott
 
Old August 31st, 2016, 02:13 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Are you adding the control to Design View or Markup View? It only works in Design View.

Also, when you last added it, did you have that line in Web.config? If so, VS doesn't add it to the page (that's the whole point of having it in Web.config). If you don't have it, VS should add the reference in the page itself.

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!
 
Old August 31st, 2016, 03:05 PM
Authorized User
 
Join Date: Feb 2016
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Might have been in markup view instead of design

THAT explains it; I was probably in markup view instead of design, as I have found it more reliable to place code precisely in markup view. I will pay more attention to the view I should be in going forward, and stick to design view when inserting objects (controls, etc.).

Thank You again, that had me a bit confused/concerned!

scott

Last edited by cadtools; August 31st, 2016 at 03:05 PM.. Reason: syntax/ past-present case





Similar Threads
Thread Thread Starter Forum Replies Last Post
required field validator rocksbhavesh ASP.NET 1.0 and 1.1 Basics 2 June 30th, 2007 03:20 AM
Custmization in Required Field validator shivendra012 ASP.NET 1.0 and 1.1 Professional 1 April 19th, 2007 05:14 AM
What's wrong with required field validator? bhavna General .NET 1 February 8th, 2007 10:25 AM
Required Field Validator RGB ASP.NET 1.0 and 1.1 Basics 3 March 31st, 2006 03:31 PM





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