p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 6th, 2006, 10:25 AM
Registered User
 
Join Date: Jun 2006
Location: Charlotte, NC, USA.
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old June 9th, 2006, 07:11 PM
Registered User
 
Join Date: Jun 2006
Location: Charlotte, NC, USA.
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old June 10th, 2006, 03:47 AM
Imar's Avatar
Wrox Author
Points: 33,563, Level: 80
Points: 33,563, Level: 80 Points: 33,563, Level: 80 Points: 33,563, Level: 80
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,231
Thanks: 7
Thanked 203 Times in 201 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old June 10th, 2006, 10:05 AM
Registered User
 
Join Date: Jun 2006
Location: Charlotte, NC, USA.
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old June 10th, 2006, 10:11 AM
Imar's Avatar
Wrox Author
Points: 33,563, Level: 80
Points: 33,563, Level: 80 Points: 33,563, Level: 80 Points: 33,563, Level: 80
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,231
Thanks: 7
Thanked 203 Times in 201 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old June 10th, 2006, 01:12 PM
Registered User
 
Join Date: Jun 2006
Location: Charlotte, NC, USA.
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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old June 11th, 2006, 03:55 AM
Imar's Avatar
Wrox Author
Points: 33,563, Level: 80
Points: 33,563, Level: 80 Points: 33,563, Level: 80 Points: 33,563, Level: 80
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,231
Thanks: 7
Thanked 203 Times in 201 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old June 11th, 2006, 10:09 AM
Registered User
 
Join Date: Jun 2006
Location: Charlotte, NC, USA.
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?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #9 (permalink)  
Old June 11th, 2006, 11:09 AM
Imar's Avatar
Wrox Author
Points: 33,563, Level: 80
Points: 33,563, Level: 80 Points: 33,563, Level: 80 Points: 33,563, Level: 80
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,231
Thanks: 7
Thanked 203 Times in 201 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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #10 (permalink)  
Old June 11th, 2006, 12:06 PM
Registered User
 
Join Date: Jun 2006
Location: Charlotte, NC, USA.
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.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 page 364 lcsgeek BOOK: Professional DotNetNuke 4: Open Source Web Application for ASP.NET 2.0 ISBN: 0-471-78816-3 2 March 10th, 2007 11:48 PM
Chapter 13 page 444 DRAYKKO Beginning VB 6 1 April 19th, 2006 08: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
chapter 13 page 358 jtwl_ BOOK: Beginning Visual C# 1 October 7th, 2003 10:28 AM



All times are GMT -4. The time now is 05:49 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc