If you are designing a UserControl for a WebForm perhaps you can test
to see if System.Web.HttpContext.Current is null or not. If its null,
then you are inside the IDE else the UserControl is deployed.

Would you mind posting the constructor of your UserControl? I've never
had to make a constructor for a UserControl. I do things inside the
Load or Init events (i.e. Page_Load, Page_Init, etc.). Is the standard
UserControl init code:

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
                
/// <summary>
///             Required method for Designer support - do not modify
///             the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion

not working for some reason?

--- Pablo Lopez <[EMAIL PROTECTED]> wrote:
> Gilles Bayon wrote:
> > The initialisation must be done on the init of the application and
> not
> > on an element of the UI.
> > -Gilles
> 
> Thanks a lot Gilles, but let me explain it more clearly cause even 
> though I understand what you mean I don't really get the point...
> 
> The fact:
> 
> I've designed a UserControl (component) which is basically a listBox 
> that "loads a list of users using iBatis" in its constructor. I want 
> that component to be that: a component, working by itself. There are
> no 
> problems when designing the component, everything is fine.
> 
> The problem arises when I drag that component to a Form in a
> particular 
> application, cause the IDE tries to instantiate my UserControl and
> the 
> environment is set to the IDE's, not to my component. It happens when
> I 
> drag it and it happens every time I click on it (for example if it's
> on 
> a tabControl) and it tries to render (thus instantiating) it.
> 
> The funny thing is that if I just comment the "load a list of users 
> using iBatis" from my UserControl's constructor, I can drag it, click
> on 
> it, etc... and then just save and close the design view of my 
> application, uncomment it, and compile it.
> 
> It obviously compiles and runs okay, but as you can imagine doing
> that 
> kind of stuff everytime I need to change something in mi design
> really 
> sucks.
> 
> I don't really find an easy way to program graphical UserControls 
> (independent components) which use iBatis on the constructur which I
> can 
> just drag to my application.
> 
> Thanks a lot for your patience,
> 
> Pablo.
> 

Reply via email to