Wrox Programmer Forums
|
BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X
This is the forum to discuss the Wrox book Professional Web Parts and Custom Controls with ASP.NET 2.0 by Peter Vogel; ISBN: 9780764578601
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 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 11th, 2011, 12:25 PM
Authorized User
 
Join Date: Dec 2007
Posts: 48
Thanks: 4
Thanked 0 Times in 0 Posts
Default Problem with BookInfo object in Chapter 9

Hey,

I'm working the example in Chapter 9, but when I try to add the subobjects, the author property is not in the intellisense list. Also I get an error when I try to use the description property, something about it being a type but is being used as property.

Here is my code:

<code>
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BookInfoCS
{
[
ParseChildren(false)]
[
ToolboxData("<{0}:BookInfo runat=server></{0}:BookInfo>")]
publicclassBookInfo : WebControl
{
privatestring _MainTitle;
privatestring _SubTitle;
privateArrayList _Authors = newArrayList();
privateArrayList _ChildControls;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[
NotifyParentProperty(true)]
[
PersistenceMode(PersistenceMode.InnerProperty)]
publicstring MainTitle
{
get { return _MainTitle; }
set { _MainTitle = value; }
}
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[
NotifyParentProperty(true)]
[
PersistenceMode(PersistenceMode.InnerProperty)]
publicstring SubTitle
{
get { return _SubTitle; }
set { _SubTitle = value; }
}
//[PersistenceMode(PersistenceMode.InnerProperty)]
publicArrayList Authors
{
get { return _Authors; }
set { _Authors = value; }
}
privatestring _Description;
publicstring Description
{
get { return _Description; }
set { _Description = value; }
}
publicArrayList ChildControls
{
get { return _ChildControls; }
set { _ChildControls = value; }
}
protectedoverridevoid AddParsedSubObject(object obj)
{
if (obj isAuthor)
{
if (_Authors == null)
{
_Authors =
newArrayList(2);
}
this.Authors.Add(obj);
}
if (obj isTitles)
{
this.MainTitle = ((Titles)obj).Main;
this.SubTitle = ((Titles)obj).SubTitle;
}
if (obj isLiteralControl)
{
Description ds;
ds = (
Description)obj;
this.Description = ds.Text;
}
if (obj isLabel)
this.Controls.Add((WebControl)obj);
}
protectedoverridevoid Render(HtmlTextWriter writer)
{
//base.Render(writer);
writer.Write("<Table>");
foreach (Author aut inthis.Authors)
{
writer.Write(
"<tr>");
writer.Write(
"<tc>" + aut.FirstName + "</tc");
writer.Write(
"<tc>" + aut.LastName + "</tc>");
writer.Write(
"</tr>");
}
writer.Write(
"</Table>");
}
}
publicclassAuthor
{
privatestring _FirstName;
privatestring _LastName;
publicstring FirstName
{
get { return _FirstName; }
set { _FirstName = value; }
}
publicstring LastName
{
get { return _LastName; }
set { _LastName = value; }
}
public Author()
{
//
// TODO: Add constructor logic here
//
}
}
publicclassTitles
{
privatestring _MainTitle;
privatestring _SubTitle;
publicstring Main
{
get { return _MainTitle; }
set { _MainTitle = value; }
}
publicstring SubTitle
{
get { return _SubTitle; }
set { _SubTitle = value; }
}
}
publicclassDescription : LiteralControl
{
}

Any help ...!

Tom
}
</code>
__________________
Thomas G Magaro





Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 13: context object problem dany96 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 July 9th, 2011 07:30 AM
Chapter 14: Object not set ksnortum BOOK: Beginning ASP.NET 4 : in C# and VB 11 January 5th, 2011 05:13 PM
Chapter 9 Object not Queryable ja11946 BOOK: Professional ASP.NET 4 : in C# and VB 1 December 5th, 2010 03:20 PM
chapter about object datasource and gridview? asptwodev BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 November 2nd, 2007 12:53 PM





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