Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : 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 18th, 2013, 02:43 AM
Authorized User
Points: 96, Level: 1
Points: 96, Level: 1 Points: 96, Level: 1 Points: 96, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 17
Thanks: 0
Thanked 1 Time in 1 Post
Default on page 522

After writing the code below

If (e.Entity IsNot Nothing) Then
Dim myPhotoAlbum As PhotoAlbum = CType(e.Entity, PhotoAlbum)
Response.Redirect(String.Format("ManagePhotoAlbum. aspx?PhotoAlbumId={0}",
myPhotoAlbum.Id.ToString()))

When I run the page and Insert the Item I don't get redirected but get an error saying:

Unable to cast object of type PlanetWroxModel.PhotoAlbum to type PhotoAlbum

Why is this??????
 
Old August 18th, 2013, 07:16 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

What's the name of the page you're using this code in? Maybe you called it PhotoAlbum.aspx instead of NewPhotoAlbum.aspx? If that's the case, .NET can't differentiate between the model class PhotoAlbum and the Web Form PhotoAlbum. Either rename the page (as well as the class name in the code behind and in the @Page directive), or recreate the page, or prefix PhotoAlbum in the code you posted with this namespace from the model (e.g. something like PlanetWroxModel.PhotoAlbum).

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!




Similar Threads
Thread Thread Starter Forum Replies Last Post
PDF giving first page as blank if page count > 1 using xsl:fo srmxslca XSLT 14 May 5th, 2011 05:01 AM
can’t open the page because the server where this page is located isn’t responding m_alsobaai Forum and Wrox.com Feedback 3 July 15th, 2010 06:13 AM
Chapter15 Pg 522 NickT BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 July 23rd, 2009 03:43 AM





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