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 June 20th, 2006, 09:24 PM
Registered User
 
Join Date: Jan 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default xxx_Init( ... ) design-time method?

Hi,

On page 72 in the example C# code, there is a method:

Private BookDisplay_Init(object sender, EventArgs e)
{
    ...
}

with reference to that this method is called at design-time so the Custom Control can be displayed in the ASPX's design-view, however I couldnt seem to get this to work. Intellisense didn't seem to see it, should there be a capital 'P' in Private? Is there a return type? (I put in 'void' so the compiler recognised it). Also, the downloadeable code doesn't seem to have it.

Can you please help me on this?

Cheers,
Jack.

 
Old July 31st, 2006, 09:35 PM
Authorized User
 
Join Date: Jul 2006
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to .MAttButler
Default

Hang in there, Chapter 3 is next on my list...

 
Old August 7th, 2006, 08:54 PM
Authorized User
 
Join Date: Jul 2006
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to .MAttButler
Default

I sat down and got through most of it this evening. Watch for it tomorrow evening.

 
Old August 8th, 2006, 06:52 PM
Authorized User
 
Join Date: Jul 2006
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to .MAttButler
Default

The two OnInit() methods (his says BookDisplay_Init() but...) Pete is refering to on page 72 are the overridden from the base class. Here is an example that I whipped up real quick. If you want to see the design time OnInit() methods called during design time see the instructions below this code:

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 MyWebControls
{
    [ToolboxData("<{0}:BookDetail runat=server></{0}:BookDetail>")]
    public class BookDetail : Label
    {
       protected override void OnInit(System.EventArgs e)
        {
            this.EnsureChildControls();
        }
        protected override void CreateChildControls()
        {
            TextBox txt = new TextBox();
            txt.ID = "fred";
            txt.Text = "Hello, World";
            this.Controls.Add(txt);
            base.CreateChildControls();
            this.ChildControlsCreated = true;
        }
    }

}

1. Create a project that contains only your Custom Server Controls.

2. Go to Project - > MyWebControls Properties - > Debug

3. Under "Start Action" choose "Start external program" and designate your IDE as the one to start during debug. Mine was here: "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"

4. Set some break points in the OnInit() and CreateChildControls() overrides.

5. Start debug. An new instance of the IDE will start. Now load the web project that you're going to use your control into the newly opened instance of the IDE.

6. Go through the process of adding your custom control to the tool box.

7. Drag your control onto a web form.

8. Your original IDE (the one that has your server controls and that you launched debug from) should now "bust upon" a break point. Yeeeee Haaaawl!!! :)

Let me know if you have any troubles with it.. or, better yet, let me know if you have a better way of debugging design time behavior of server controls.
The Following User Says Thank You to .MAttButler For This Useful Post:
rickjackson (January 1st, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing in Design Time Farside Visual Studio 2005 1 August 9th, 2007 06:42 PM
Design Time Exception in WinForm doctorwcc VB.NET 0 March 2nd, 2007 04:00 AM
Design-Time or Run-Time now ? ALGNET .NET Framework 2.0 1 July 31st, 2006 04:43 AM
Setting Design time property in webcustom control c_cicilia ASP.NET 1.x and 2.0 Application Design 1 September 23rd, 2004 10:35 PM





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