Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 22nd, 2019, 07:01 PM
Authorized User
Points: 44, Level: 1
Points: 44, Level: 1 Points: 44, Level: 1 Points: 44, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2019
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 14 Error in "Try It Out" p. 505 Simple Model Binding

This is regarding the Try It Outs in Chapter 14
p. 505 "Try It Out: A Simple Model Binding Application"

In building the "NewPhotoAlbum.aspx." I've done this twice, the second time I started this chapter over by copying all the source code from the Chapter 13 folder and adjusting the connection string to reflect my database (I could never get it to work with the .mdf file, so I just put a connection to my local SQL Server instance). But back to the point... several problems occurred:

In Step 8, I was unable to get intellisense on the InsertMethod and when I typed it anyway and entered the = sign, I did not get the "CreateNewMethod." So in the codebehind I manually created DetailsView1_InsertItem. The problem is that VS does not like TryUpdateModel or ModelState. I get red underlines on those two. When viewing the author's code for Chapter 14, I don't see those being explicitly defined anywhere. So what am I missing??

Then in the ListView TryItOut, same thing. Page 515, VS does not like the QueryString("PhotoAlbumId"). Ctrl+. does not bring up any menus but I copied the Imports statement from your code only to get a green underline saying that the import is not necessary, and it doesn't remove the red line under PhotoAlbumID.

If I just copy your Chapter 14 code and run it as-is, it would work fine. Yet I directly copied your Chapter 13 code (making the adjustments to my connectionstring) and followed every single step and the yet code is STILL breaking all over the place! What is happening??!!

P.S. If this is "simple" model binding I'd hate to see the advanced one. IMHO I don't think something like belongs in a "Beginning" book! I barely even understand half of what I'm typing in and I sure as heck will not remember any of it later if I have to duplicate this.
Reply With Quote
  #2 (permalink)  
Old April 23rd, 2019, 05:08 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

>> In Step 8, I was unable to get intellisense on the InsertMethod and when I typed it anyway and entered the = sign, I did not get the "CreateNewMethod."

That sounds like an issue with the page. Could it be that you copied an existing page and now have a name collision? Is there anything in the error list that could explain what's going on?

Can you uploaded a zipped copy of the page and its code behind somewhere so I can take a look?

Cheers,

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!
Reply With Quote
  #3 (permalink)  
Old April 23rd, 2019, 11:58 PM
Authorized User
Points: 44, Level: 1
Points: 44, Level: 1 Points: 44, Level: 1 Points: 44, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2019
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Default Link to my site.

I appreciate the offer! I am not allowed to attach files but hopefully you can get my version from here https://www.dropbox.com/s/aba0b54g9p9n4xi/Site.zip?dl=0

A couple of notes: I am not using the .mdf file for the database since I could never get that to work. The connectionstring points directly to my SQL Server instance. Also, apparently at one point we were supposed to switch the database from PlanetWroxTemp to PlanetWrox. I didn't get that memo, so my DB is still PlanetWroxTemp and so are the entities.

Thanks!
Reply With Quote
  #4 (permalink)  
Old April 25th, 2019, 04:12 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I downloaded your source code and it works fine for me. Here's what I did:

1. Downloaded and extracted source code
2. Opened as Web Site (File | Open | Web site) in Visual Studio 2017
3. Attached an existing PlanetWrox database as PlanetWroxTemp to my SqlExpress instance
4. Opened NewAlbum and entered a name
5. I was redirected to ManagePhotoAlbum and the album exists in the database.

I also get IntelliSense on the Insert method:

https://i.imgur.com/Ma8cThP.png

And no errors in the code behind:

https://i.imgur.com/XmaXjJr.png

Which version of Visual Studio are you using exactly (check Help | About)

Cheers,

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!
Reply With Quote
  #5 (permalink)  
Old April 25th, 2019, 01:51 PM
Authorized User
Points: 44, Level: 1
Points: 44, Level: 1 Points: 44, Level: 1 Points: 44, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2019
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Imar. I was using 2017 but now I'm using the latest VS Community 2019.

I'm still having the red underlines although the app does work for adding new albums. Perhaps I'm missing packages? I have in Nuget EntityFramework, JQuery, Microsoft.Aspnet.FriendlyUrls.Core, Microsoft.Asp.net.ScriptManager.Webforms and Modernizr.

I looked up TryUpdateModel and see that it's in the System.Web.MVC class. But when I type
Code:
Imports System.Web.MVC
I get a green underline saying that import is unnecessary and it doesn't contain any public code.

Here is a screen shot of my build errors:

https://www.dropbox.com/s/kbrl84agvz...09-18.jpg?dl=0

Last edited by servo75; April 25th, 2019 at 02:11 PM..
Reply With Quote
  #6 (permalink)  
Old April 25th, 2019, 06:29 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

If your code works fine, check the following:

- Using Windows Explorer, check if your site contains other files than you think and see in the Solution Explorer?If so, you may want to delete those.
- Maybe VS is just confused. Using Windows Explorer (with VS shut down), look in the folder where your solution file is located. Do you see a .vs folder? If so, delete it. Note: the folder may be hidden. Then restart VS
- Right-click the solution and click Clean. You may have outdated binaries in your bin folder.

If that all fails, I am not sure what to recommend next.

Cheers,

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!
Reply With Quote
  #7 (permalink)  
Old April 25th, 2019, 09:31 PM
Authorized User
Points: 44, Level: 1
Points: 44, Level: 1 Points: 44, Level: 1 Points: 44, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2019
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Imar, I am getting ready to give up on this because this project is just becoming too complicated anyway. I'm thinking I should be able to solve this easily on my own but I just am getting confused with the classes and packages we're using. I'm willing to try one more thing.

I think possibly when I copy your code, because it's older, it's screwing up my packages and I don't have the right libraries in. Because as-is, the code is pointing to the wrong folders for the DLL files and I have to fix them. That may explain why I'm getting underlined methods. This is what I have installed in NuGet. Does it look like there's anything missing?

* EntityFramework
* jQuery
* Microsoft.AspNet.FriendlyUrls.Core
* Microsoft.AspNet.ScriptManager.WebForms
* Modernizr

In the bin folder, I have the following DLLs
* EntityFramework.dll
* EntityFramework.SqlServer.dll
* Microsoft.AspNet.FriendlyUrls.dll
* Microsoft.ScriptManager.WebForms.dll
Reply With Quote
  #8 (permalink)  
Old April 29th, 2019, 10:13 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yeah, that looks fine.

Which files did you copy over? Simple files like web forms and code behind aren't tied to any specific package so they should just work. The EF model files do depend on specific versions, so they may not work when copied over from my code.

Cheers,

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!
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 15. "Sign Up for new account" gets error: 26 - Error Locating Server/Instance Tanya Roslyakova BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 March 8th, 2011 10:34 AM
MSXSL gives error message for "for" inside "select" ilyaz XSLT 1 December 9th, 2010 05:02 PM
Chapter 18: Getting "Failed to generate a user instance of SQL Server" error HungryCaterpillar BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 November 11th, 2009 01:56 PM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
Chapter 29, The "Simple" Exercise slginps BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1 1 April 25th, 2009 01:40 PM



All times are GMT -4. The time now is 06:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.