Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 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 June 6th, 2006, 09:25 AM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in code Chapter 13 Page 516

I get the following error:
BC30311: Value of type 'Login' cannot be converted to 'System.Web.UI.WebControls.Login'

I typed and copied your code and it doesn't work. HELP!!

It is having problems with:
Dim l As System.Web.UI.WebControls.Login = CType(Me.Wizard_checkOut.FindControl("Login1"), Login)

Chapter 13 Pge 516
 
Old June 9th, 2006, 06:11 PM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is anyone from WROX monitoring this forum?
I have a problem with your code that you provided in your book.

Please Help

 
Old June 10th, 2006, 02:47 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 may need to add an Imports statement for System.Web.UI.WebControls at the top of your page.

If it's already there, maybe your page is also called Login and then code gets confused about whether you're referring to the page class instead of the Login control? If that's the case, try this instead:

Dim l As System.Web.UI.WebControls.Login = _
    CType(Me.Wizard_checkOut.FindControl("Login1"), System.Web.UI.WebControls.Login)

By explicitly naming the namespace for the control, there's no confusion about what Login you're referring to...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old June 10th, 2006, 09:05 AM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I still get the following error:

Compiler Error Message: BC30311: Value of type 'Login' cannot be converted to 'System.Web.UI.WebControls.Login'

I added the import statement:
Imports System.Web.UI.WebControls

and I explicitly named the namespace for the control:

Line 69: Protected Sub Wizard_checkOut_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArg s) Handles Wizard_checkOut.NextButtonClick
Line 70: If e.CurrentStepIndex = 0 Then
Line 71: Dim l As System.Web.UI.WebControls.Login = CType(Me.Wizard_checkOut.FindControl("Login1"), Login)
Line 72:
Line 73: If Membership.ValidateUser(l.UserName, l.Password) Then

Is this the recommended way to set the "remember me" check and see if the user is vaidated? If the user has login - then why use the membership.validateuser method instead of user.isauthinticated?

Sorry for all the questions; however, I am trying to:
1. understand the concepts that you are covering in your book and
2. figure out this bug in your code.

Please help! This chapter had allot of concepts thrown at us just to get the "Check Out" control to work. I searched your forum and I see that either:
A. I am the only one who is having problems with your code on this chapter
or
B. I am the only one who has reached chapter 13

 
Old June 10th, 2006, 09:11 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Did you try changing this:

CType(Me.Wizard_checkOut.FindControl("Login1"), Login)


to this:

CType(Me.Wizard_checkOut.FindControl("Login1"), 'System.Web.UI.WebControls.Login)

Is your page indeed called Login?

IsAuthenticated returns true after a user successfully authenticated. However, before this is tue, you need to authenticate first. That's what ValidateUser does. Usually, you don't need to write all this, because the Login control handles authentication for you.

Sorry I don't have more answers. I don't have the book so I don't know what the code is supposed to do.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old June 10th, 2006, 12:12 PM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much - it works!
This is how the dim statement looks:
 Dim l As WebControls.Login = CType(Me.Wizard_checkOut.FindControl("Login1"), System.Web.UI.WebControls.Login)

I explicitly named the namespace for "l" and not for the CType statement.

I see what you are saying about validating users. When I go through these books, I look at the meaning more than the method. In this example, I don't know if I would write my own validation sub; however, it did show me the power of the Membership class and how your can use the ValidateUser method. I would have like to see an example of the Membership.CreateUser method since most folks will want to store more information about a user than their name and e-mail address.

Now that it is working, I will step through the code and see how the "Check-Out" page works.

Again, thanks for your help.

PS: On another topic - why don't folks who program ASP 2.0 create user controls instead of classes? There seems to be more advantages in creating user controls with custom events and properties than a class.

 
Old June 11th, 2006, 02:55 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think what eventually went wrong is that you had a page called Login. The Code Behind of that page is then a class called Login. When you try this code:

Dim l As Login = CType(Me.Wizard_checkOut.FindControl("Login1"), Login)

the compiler doesn't know whether the last Login refers to your current page (the class Login) or the a System.Web.UI.WebControls.Login control.
Quote:
quote:On another topic - why don't folks who program ASP 2.0 create user controls instead of classes?
I am not sure I understand what you're asking here....

Just like many any other .NET elements, a User Controls is a class as well. It derives from TemplateControl which in turn derives from Control which ultimately derives from Object, the base class for all classes.

So what classes instead of user controls are you referring to?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old June 11th, 2006, 09:09 AM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wrox book Beginning ASP.NET 2.0 had us create a class called shopping cart. It contained the methods used to create, insert, delete, and update items in the cart. These methods were used with a user control called Shopping Cart. Since the user control can be placed in any other page or control and is consider a class itself, why separate these two. Why do programmers make classes instead of User Controls? Even if the user control didn't have any design elements such as server controls, it would still be a class that can be drop on any page and used like a custom class.

I am a student that is studying the three tier programming. While this method seems great with windows applications, it seems that would be hard to apply with ASP - until now.

With ASP.NET 2.0 you would use the dataset.xsd files as your data access layer, user controls as your business layer, and web page.aspx(.vb) as your presentation layer.

It seems like a simple solution that would maximize ASP.NET 2.0 features; however, most books don’t mention this architecture. Your book is the first book that even mentions the dataset.xsd and how it is used. My fellow programmers all use custom classes to work with their pages – only.

I am asking your option, as an established programmer, if this programming architecture would not be a good way in programming new ASP.NET 2.0 web applications. What is the pro’s or con’s to this architecture?


 
Old June 11th, 2006, 10:09 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

First of all, if you're talking about Beginning ASP.NET 2.0, it's not my book. I didn't write it, nor contribute to it. I only answered your question in this forum.

Personally, I don't see User Controls as business logic; I see them as part of the presentation layer as well. By adding properties and methods to user controls, pages that contain them can influence their look and feel and behavior.

However, behind the scenes, these user controls still talk to business layer classes that can live in either the App_Code folder or a separate class library.

Separating them brings some advantages, with code resue being one of them. For example, for a large site I built, I have a class library that contains all the business logic and talks to the DAL. This class library is used in the main site, but an identical copy of the assembly is used in a Content Management System that is built to manage the site (on a completely different URL). This way, we have complete control over the code, while we still reuse 100% of it. Each site simply talks to this Business Layer, and controls its own look and feel through User Controls and Pages.

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Bad Habit by The Offspring (Track 3 from the album: Smash) What's This?
 
Old June 11th, 2006, 11:06 AM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes it does.

I come from a JAVA based - object oriented type programming. I like JAVA beans - meaning creating objects that can be used in other objects.

In ASP.NET 2.0 - I was really excited to see a Custom User Control (CUC) can be place in another control such as a wizard control. You can even place a Custom User Control in another Custom User Control (CUC). For example you can make a “Check Out” Custom User Control that contains a “Shipping” CUC, “Pay-Pal” CUC, and “Invoicing” CUC.

I also like the Dataset.xsd that can access any database and create methods based on SQL or Stored Procedures. Each Dataset.xsd can contain many table adapters and methods with the tools to create and test these methods. This greatly reduces the coding needed to open an connection, create a dataset, load the dataset, and then closing the connection.

I was impressed that I could create several similar web applications simply by using the same dataset.xsd and Custom User Controls (CUC). All I had to do is drop a CUC on a web page and call on its public methods just like I would do with a custom class. In theory, a programmer could have sever CUC such as: Purchase Orders, Invoices, Customer information, Shopping cart, etc. that would help create custom web applications quickly (assuming they access the say database structure).

When I started reading and trying out classes, I started getting confused on my approach on how to efficiently code web application.
I can see the advantage in having all your business logic in one class (VB File).

Of course there is many ways to program an application; I am always looking into the latest programming languages to exploit their advantages to expedite programming efficient applications.

Again, thanks for your help.
Any suggestions, Programming tips or books to read would be appreciated.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 page 444 DRAYKKO Beginning VB 6 1 April 19th, 2006 07:10 PM
chapter 13 building an index page drb2k2 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 5 March 5th, 2006 07:22 PM
Is Chapter 13 Code wrong??? miggitty VB.NET 2002/2003 Basics 0 December 31st, 2003 12:20 AM





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