View Single Post
  #1 (permalink)  
Old August 11th, 2011, 01:25 PM
flashmanTom flashmanTom is offline
Authorized User
Points: 222, Level: 4
Points: 222, Level: 4 Points: 222, Level: 4 Points: 222, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2007
Location: Phoenix, AZ, USA.
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