Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 20th, 2006, 10:24 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
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.

  #2 (permalink)  
Old July 31st, 2006, 10:35 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
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...

  #3 (permalink)  
Old August 7th, 2006, 09:54 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
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.

  #4 (permalink)  
Old August 8th, 2006, 07:52 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
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)
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing in Design Time Farside Visual Studio 2005 1 August 9th, 2007 07: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 05:43 AM
Setting Design time property in webcustom control c_cicilia ASP.NET 1.x and 2.0 Application Design 1 September 23rd, 2004 11:35 PM



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


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