Wrox Programmer Forums
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
|
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
 
Old March 19th, 2016, 06:30 AM
Registered User
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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>
 
Old March 19th, 2016, 09:48 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
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!
 
Old March 19th, 2016, 11:24 AM
Registered User
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
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
 
Old March 19th, 2016, 03:09 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
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!
 
Old March 21st, 2016, 02:14 PM
Registered User
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
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
 
Old March 21st, 2016, 03:30 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
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!
 
Old March 22nd, 2016, 01:12 PM
Registered User
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
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
I have used website Project and PhotoAlbum.cs file doesn't have anything it since there was squiggly line under the PhotoAlbum i generated the class but now i have deleted that file. You asked few other details please check below links. I hope these screen shots would be enough to figure out the problem.

I really appreciate your help Mr. Imaar.

http://server.myspace-shack.com/d21/database.jpg
http://server.myspace-shack.com/d21/planetwroxedmx.jpg
http://server.myspace-shack.com/d21/...onexplorer.jpg
http://server.myspace-shack.com/d21/...nemessage2.jpg
http://server.myspace-shack.com/d21/...nemessage1.jpg
http://server.myspace-shack.com/d21/tables.jpg
http://server.myspace-shack.com/d21/screenshot10369.jpg
 
Old March 23rd, 2016, 09:08 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
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!
 
Old March 23rd, 2016, 10:10 AM
Registered User
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
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
 
Old March 23rd, 2016, 11:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

>> Can you zip the site and database and make it available online somewhere?

This is a RAR, can you make it a ZIP?

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
Chapter 14 Third Try It Out A Simple Model Binding Application, p.505 arvalon BOOK: Beginning ASP.NET 4.5.1 : in C# and VB 3 February 17th, 2016 07:47 AM
chapter 14,Try it out in page 505 and 513 shameema BOOK: Beginning ASP.NET 4.5.1 : in C# and VB 16 March 29th, 2015 03:27 AM
Chapter 14: Simple EntitySource Application try-it out K_Joe BOOK: Beginning ASP.NET 4 : in C# and VB 7 February 16th, 2014 05:00 PM
Chapter 14 : Mapping data model to an object model robochrish BOOK: Beginning ASP.NET 4 : in C# and VB 8 March 5th, 2013 09:52 AM
CH 14 A Simple EntityDataSource Application - Error! leeWozyWarren BOOK: Beginning ASP.NET 4 : in C# and VB 5 December 7th, 2011 02:28 PM





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