So klappts tats�chlich auf den ersten Blick. Leider wird aber in Visual Studio
 in der Vorschau nur ein weisser Fleck angezeigt. Also habe ich versucht
ein Designer zu implementieren, etwa so:

public class MyDesigner : ControlDesigner
        {
                public NodeDesigner()   {}
                
                public override string GetDesignTimeHtml()
                {
                return base.GetDesignTimeHtml();
                }
        }

Funktioniert jedoch nicht - Keine Vorschau...


>-- Original-Nachricht --
>From: "Andreas Rudischhauser" <[EMAIL PROTECTED]>
>To: <[email protected]>
>Subject: AW: AW: [Asp.net] Einfaches Custom Control Problem?
>Reply-To: [email protected]
>Date: Thu, 6 Jan 2005 13:24:22 +0100
>
>
>Also 
>
>1. Dein fehler kommt daher, dass du das Image "image" nicht mit new Image()
>initialisiert hattest. Dann kannst du nat�rlich auch nicht mit .ImageUrl
>darauf zugreifen.
>
>2. So ist aber besser programmiert. Controls sollten nur in
>CreateChildControls zusammengesetzt werden. Wenn man es genau nimmt solltest
>du die Daten sogar erst in PreRender() einf�gen.
>
>
>using System;
>using System.Web.UI;
>using System.Web.UI.WebControls;
>using System.ComponentModel;
>
>namespace test
>{
>       /// <summary>
>       /// Summary description for WebCustomControl1.
>       /// </summary>
>       [DefaultProperty("Text"), 
>       ToolboxData("<{0}:MyButton runat=server></{0}:MyButton>")]
>       public class MyButton : WebControl
>       {
>               //Used by toggleImage
>               private Image toggleImage = new Image();
>               private Image normalImage = new Image();
>               
>               //Defines which image to display
>               private bool expanded = true;
>       
>               [Bindable(true), 
>               Category("Appearance"), 
>               DefaultValue(true)] 
>               public bool Expanded
>               {
>                       get
>                       {
>                               return this.expanded;
>                       }
>
>                       set
>                       {
>                               this.expanded = value;
>                       }
>               }
>               
>
>               [Bindable(true), 
>               Category("Appearance"), 
>               DefaultValue("")] 
>               public string ImageUrlExpanded 
>               {
>                       get
>                       {
>                               return this.imageUrlExpanded;
>                       }
>                       set
>                       {
>                               this.imageUrlExpanded = value;
>                       }
>               }
>               private string imageUrlExpanded = "";
>
>               [Bindable(true), 
>               Category("Appearance"), 
>               DefaultValue("")] 
>               public string ImageUrlCollapsed 
>               {
>                       get
>                       {
>                               return this.imageUrlCollapsed;
>                       }
>
>                       set
>                       {
>                               this.imageUrlCollapsed = value;
>                       }
>               }
>               private string imageUrlCollapsed = "";
>
>               [Bindable(true), 
>               Category("Appearance"), 
>               DefaultValue("")] 
>               public string ImageUrl
>               {
>                       get
>                       {
>                               return this.imageUrl;
>                       }
>
>                       set
>                       {
>                               this.imageUrl = value;
>                       }
>               }
>               private string imageUrl = "";
>
>
>
>               protected override void CreateChildControls()
>               {
>                       this.toggleImage.ImageUrl = (this.expanded) ?
>this.imageUrlExpanded : this.imageUrlCollapsed;
>            this.Controls.Add(toggleImage);
>
>                       this.normalImage.ImageUrl = this.imageUrl;
>                       this.Controls.Add(normalImage);
>               }
>       }
>}
>
>
>_______________________________________________
>Asp.net Mailingliste, Postings senden an:
>[email protected]
>An-/Abmeldung und Suchfunktion unter:
>http://www.glengamoi.com/mailman/listinfo/asp.net

_______________________________________________
Asp.net Mailingliste, Postings senden an:
[email protected]
An-/Abmeldung und Suchfunktion unter:
http://www.glengamoi.com/mailman/listinfo/asp.net

Antwort per Email an