p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X (http://p2p.wrox.com/forumdisplay.php?f=225)
-   -   Chapter 12 (http://p2p.wrox.com/showthread.php?t=47332)

.MAttButler September 3rd, 2006 08:03 PM

Chapter 12
 
Chapter 12 is almost done, I'll be posting it shortly.


.MAttButler September 7th, 2006 08:25 PM

I've posted Chapter 12 at http://100days.net/wrox/

The customization and communication from that chapter aren't implemented yet. That's next. I'll update the code with it as soon as it's done.


czone September 9th, 2006 05:47 PM

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

czone September 10th, 2006 05:20 PM

Forget my previous post, I was able to resolve the issue by manually selecting the DLL when adding an item to the tool box.

Thanks!

czone

czone September 10th, 2006 05:25 PM

I do have a question related to page 421 - Displaying User Data on Postback.

The text is not clear as to where the code should go. I put it in the IPostBackDataHandler.LoadPostData method (see page 413) but I get errors telling me that the txtName & others are not recognized.

So where should the code on page 421 go? Is it a new method or should it be added to an existing method? If an existing method, which one?

I also get an error telling me that the public modifier is not balid for the IPostBackDataHandler.LoadPostData method. This is fixed by not putting a modifier on it but I don't think this is the best way to fix the error. How should this error be fixed?

Thanks,
Czone

czone

.MAttButler September 10th, 2006 08:31 PM

Have you had a chance to download the newer version of Chapter 12's code, yet? Get it from here and take a look at it. Let's work from that codebase to get to your answers. The text leaves out a few crucial details but you'll see where those methods should be in the newer code. Let me know what your questions are after you look through it.





All times are GMT -4. The time now is 01:02 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.