Thread: Chapter 12
View Single Post
  #3 (permalink)  
Old September 9th, 2006, 05:47 PM
czone czone is offline
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm trying to walk through chapter 12 and I'm on page 392 where it tells me to compile to see my control in my toolbox like figure 12.5.

I've built the project, there is a reference to it in test web project, but I still don't see it in the toolbox.

My code is below.

Is there something missing from the code?
Thanks in advance for any help!
czone

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CaseStudyControlsCS
{
    [ToolboxData("<{0}:CustomerInformation runat=server></{0}:CustomerInformation>")]
    public class CustomerInformation : System.Web.UI.WebControls.WebParts.WebPart
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (this.DesignMode == true)
            {
                this.EnsureChildControls();
            }
        }

        protected override void CreateChildControls()
        {

            System.Web.UI.WebControls.Style st = new System.Web.UI.WebControls.Style();

            if (this.ControlStyleCreated == true)
            {
                st = this.ControlStyle;
            }
            else
            {
                st = new System.Web.UI.WebControls.Style();
            }

            System.Web.UI.WebControls.Label lblName = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblEmail = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblStreet = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblCity = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblStateProvince = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblCountry = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblNameLb = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblEmailLb = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblStreetLb = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblCityLb = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblStateProvinceLb = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblCountryLb = new System.Web.UI.WebControls.Label();

            lblName.ID = "lblName";
            lblName.Attributes["DisplayType"] = "label";

            lblEmail.ID = "lblEmail";
            lblEmail.Attributes["DisplayType"] = "label";

            lblStreet.ID = "lblStreet";
            lblStreet.Attributes["DisplayType"] = "label";

            lblCity.ID = "lblCity";
            lblCity.Attributes["DisplayType"] = "label";

            lblStateProvince.ID = "lblStateProv";
            lblStateProvince.Attributes["DisplayType"] = "label";

            lblCountry.ID = "lblCountry";
            lblCountry.Attributes["DisplayType"] = "label";


            lblNameLb.Text = "Name:";
            lblNameLb.Attributes["DisplayType"] = "data";

            lblEmailLb.Text = "Email:";
            lblEmailLb.Attributes["DisplayType"] = "data";

            lblStreetLb.Text = "Street:";
            lblStreetLb.Attributes["DisplayType"] = "data";

            lblCityLb.Text = "City:";
            lblCityLb.Attributes["DisplayType"] = "data";

            lblStateProvinceLb.Text = "State/Province:";
            lblStateProvinceLb.Attributes["DisplayType"] = "data";

            lblCountryLb.Text = "Country:";
            lblCountryLb.Attributes["DisplayType"] = "data";

            this.Controls.Clear();
            this.Controls.Add(lblName);
            this.Controls.Add(lblNameLb);
            this.Controls.Add(lblEmail);
            this.Controls.Add(lblEmailLb);
            this.Controls.Add(lblStreet);
            this.Controls.Add(lblStreetLb);
            this.Controls.Add(lblCity);
            this.Controls.Add(lblCityLb);
            this.Controls.Add(lblStateProvince);
            this.Controls.Add(lblStateProvinceLb);
            this.Controls.Add(lblCountry);
            this.Controls.Add(lblCountryLb);

            this.ChildControlsCreated = true;

        }

    }
}


czone