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

March 19th, 2016, 06:30 AM
|
|
Registered User
|
|
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hapter 14 Third Try It Out A Simple Model Binding Application, page 505
Hey Imar,
I am really enjoying your book however I am getting the error in chapter 14 while inserting the code in code of DetailsView1_InsertItem() behind file of NewPhotoAlbum.aspx. its gets red squiggly line uner the photoAlbum and when I hover over PhotoAlbum its says "They type and namespace name 'PhotoAlbum' couldn't be found (are you missing a using directive or name assembly reference?)"
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class NewPhotoAlbum : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void DetailsView1_InsertItem()
{
PhotoAlbum photoAlbum = new PhotoAlbum();
TryUpdateModel(photoAlbum);
if (ModelState.IsValid)
{
using (var myEntities = new PlanetWroxEntities())
{
myEntities.PhotoAlbums.Add(photoAlbum);
myEntities.SaveChanges();
}
Response.Redirect(string.Format(
"ManagePhotoAlbum?PhotoAlbumId={0}", photoAlbum.Id.ToString()));
}
}
}
HTML Code:
<%@ Page Title="Create New Photo Album" Language="C#" MasterPageFile="~/MasterPages/Management.master" AutoEventWireup="true" CodeFile="NewPhotoAlbum.aspx.cs" Inherits="NewPhotoAlbum" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="Server">
<asp:DetailsView AutoGenerateRows="false" ID="DetailsView1"
DefaultMode="Insert" runat="server">
<Fields>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:CommandField ShowInsertButton="True" ShowCancelButton="false" />
</Fields>
</asp:DetailsView>
</asp:Content>
|
|

March 19th, 2016, 09:48 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Good to hear you like the book so much.
How did you create your EF model? Did you create it in the App_Code folder and use the same name for the entities and tables names as the book uses?
Imar
|
|

March 19th, 2016, 11:24 AM
|
|
Registered User
|
|
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Imar
Hi there,
Good to hear you like the book so much.
How did you create your EF model? Did you create it in the App_Code folder and use the same name for the entities and tables names as the book uses?
Imar
|
Yeah I am using the same as you described in your book and on you asked I have rechecked everything
|
|

March 19th, 2016, 03:09 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Well, something must be different or it would work. Are you it's in App_Code and not another folder? Does the site compile without errors? Are you using a Web Site project (you can check by looking at the number of code behind files for Default.aspx: one is a Web Site Project, two is a Web Application project).
Maybe you can post a screenshot of your expanded Solution Explorer online somewhere?
Imar
|
|

March 21st, 2016, 02:14 PM
|
|
Registered User
|
|
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Imar
Well, something must be different or it would work. Are you it's in App_Code and not another folder? Does the site compile without errors? Are you using a Web Site project (you can check by looking at the number of code behind files for Default.aspx: one is a Web Site Project, two is a Web Application project).
Maybe you can post a screenshot of your expanded Solution Explorer online somewhere?
Imar
|
Dear Imar,
Sorry for replying late actually I tried to do everything again but the problem is same below is the link please see the error and advise
http://server.myspace-shack.com/d21/screenshot10369.jpg
Waiting for you response
|
|

March 21st, 2016, 03:30 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Sorry to say it but I still need more info. Like I asked earlier: do you use a Web Application Project?
Also, what does the PhotoAlbum.cs file do in App_Code and what code does it contain? What happens when you open the smart tasks panel (through the squiggly under PhotoAlbum? Did you spell PhotoAlbum for the table name the same as the class name? C# is case sensitive, so a table called Photoalbum won't become an entity called PhotoAlbum.
Since I can't see your environment setup or code, you need to provide me with more information.
Cheers,
Imar
|
|

March 23rd, 2016, 09:08 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
That all looks good so I am not sure what's going on. Do you see the PhotoAlbum class in the .cs file beneath PlanetWrox.tt? Also note your first error message which indicates PhotoAlbums (plural) is not part of your model.
Can you zip the site and database and make it available online somewhere? Then I'll take another look.
Cheers,
Imar
|
|

March 23rd, 2016, 10:10 AM
|
|
Registered User
|
|
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Imar
Hi there,
That all looks good so I am not sure what's going on. Do you see the PhotoAlbum class in the .cs file beneath PlanetWrox.tt? Also note your first error message which indicates PhotoAlbums (plural) is not part of your model.
Can you zip the site and database and make it available online somewhere? Then I'll take another look.
Cheers,
Imar
|
Hey Imar Thanks for your help. Please download the zip folder by clicking on below link. Desperately waiting for your reply
https://onedrive.live.com/redir?resi...t=folder%2crar
|
|

March 23rd, 2016, 11:46 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
>> Can you zip the site and database and make it available online somewhere?
This is a RAR, can you make it a ZIP?
Imar
|
|
 |
|