<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.aspnetzone.de/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Peter Bucher : Control Entwicklung, Artikel</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/Artikel/default.aspx</link><description>Ordnungsbegriffe: Control Entwicklung, Artikel</description><dc:language /><generator>CommunityServer 2.1 SP2 (Build: 61120.2)</generator><item><title>Artikel: ASP.NET Controls genau nach Vorlage</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2008/11/10/artikel-asp-net-controls-genau-nach-vorlage.aspx</link><pubDate>Mon, 10 Nov 2008 19:10:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:203872</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>3</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/203872.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=203872</wfw:commentRss><description>&lt;P&gt;&lt;IMG src="http://www.aspnetzone.de/photos/peterbucher/images/203871/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;In der aktuellen &lt;A href="http://www.aspnet-professional.de/"&gt;ASP.NET Professional&lt;/A&gt; 10/2008 Ausgabe&amp;nbsp; findet sich ein Artikel von mir über die Benutzung von Templates (Vorlagen) in ASP.NET Controls. &lt;BR&gt;Im Artikel werden die verschiedenen Möglichkeiten besprochen um Controls mit Templates auszustatten.&lt;/P&gt;
&lt;P&gt;Wer kein Abonnement von ASP.NET Professional besitzt, trotzdem mal reinschnuppern möchte und meinen Artikel interessant findet, kann sich ein &lt;A href="http://www.aspnet-professional.de/freemag.aspx"&gt;kostenloses Probeabo&lt;/A&gt; zukommen lassen (Dort ist der aktuelle Artikel drin).&lt;/P&gt;&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=203872" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Template/default.aspx">Template</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ITemplate/default.aspx">ITemplate</category></item><item><title>Events für User- und CustomControls definieren und benutzen</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2008/06/12/events-f-r-user-und-customcontrols-definieren-und-benutzen.aspx</link><pubDate>Thu, 12 Jun 2008 19:44:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:197542</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>1</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/197542.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=197542</wfw:commentRss><description>&lt;P&gt;In der Welt von ASP.NET gibt es - im Gegensatz zu Classic ASP - ein Eventsystem das in der ASP.NET Engine verwurzelt ist. &lt;BR&gt;Dazugehörend haben viele ASP.NET Controls Events. Das bekannteste ist wohl &lt;EM&gt;Button.Click&lt;/EM&gt;, über diesen Event kann festgestellt werden ob ein bestimmter Button gedrückt wurde, oder nicht.&lt;/P&gt;
&lt;P&gt;Nun gibt es ja die Möglichkeit eigene User- und CustomControls zu schreiben. &lt;BR&gt;Diese können mit Events ausgestattet werden, und genau um das geht es hier in diesem Artikel.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Wie funktionieren die Events in ASP.NET?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Grundsätzlich ereignen sich alle Aktionen auf dem Client, bspw. klickt eine Person an einem Computer in dessen Webbrowser auf einen Button. &lt;BR&gt;Danach wird das Formular abgesendet und der Server empfängt dieses.&lt;/P&gt;
&lt;P&gt;Der Server leitet den Http-Request (Die Http-Anfrage) an die ASP.NET Engine weiter. &lt;BR&gt;Die Engine findet dann anhand der &lt;EM&gt;&amp;lt;Control&amp;gt;.UniqueID&lt;/EM&gt; (Siehe: &lt;A href="http://www.aspnetzone.de/blogs/peterbucher/archive/2007/04/09/artikel-identifizierung-von-controls-control-id-clientid-uniqueid.aspx"&gt;Identifizierung von Controls: Control.ID / .ClientID / .UniqueID&lt;/A&gt;) das Control zu dem die jeweiligen Daten gehören.&lt;/P&gt;
&lt;P&gt;Wenn dieses Control gefunden wurde, leitet die Engine die gesamten POST-Daten (Formulardaten) an das bestreffende Control weiter. &lt;BR&gt;Sind die Daten geändert worden, bzw. befinden sich die Daten in einem erwarteten Zustand, löst das Control den Event aus, ansonsten nicht.&lt;/P&gt;
&lt;P&gt;Dies ist die normale Vorgehensweise von Events (Die Page Events laufen ähnlich ab), die über POST (Formular, Postback) ausgelöst werden.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Wie definiere ich einen Event, oder was ist ein Event überhaupt?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Für die Grundlagen zur Event-Erstellung, mit oder ohne nutzerspezifische Argumente, verweise ich hier auf den FAQ Thread des C#-Forums myCSHarp.de.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.mycsharp.de/wbb2/thread.php?threadid=26116" target=_blank&gt;Eigenen Event definieren / Information zu Events (Externer Link: myCSharp.de)&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Die &lt;A href="http://www.mycsharp.de/wbb2/board.php?boardid=70"&gt;FAQ&lt;/A&gt; von myCSharp.de als solches ist auch für andere Sprachspezifische Angelegenheit sehr zu empfehlen.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Wie / Wann werden die Events ausgelöst und gibt es mehrere Auslösearten?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Das trickreiche an Events in ASP.NET ist nicht die Dekleration der Events, sondern der Zeitpunkt an dem sie ausgelöst werden sollen. &lt;BR&gt;Es gibt tatsächlich mehrere Arten von Zustandsveränderungen bei denen ein Event ausgelöst werden kann.&lt;/P&gt;
&lt;P&gt;Folgend die Möglichkeiten von Zustandsänderungen durch einen Benutzer der Web Applikation ausgelöst:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Werte die durch einen (oder mehrere) &lt;STRONG&gt;GET-Parameter&lt;/STRONG&gt; (QueryString) empfangen werden, bspw. wenn der Benutzer auf einen Link klickt 
&lt;LI&gt;Werte die durch einen (oder mehrere) &lt;STRONG&gt;POST-Parameter&lt;/STRONG&gt; (Form) empfangen werden, bspw. wenn der Benutzer Formularfelder ausgefüllt hat und dann auf einen Button klickt, oder aber nur auf einen Button klickt &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Zudem gibt es noch weitere Faktoren und Möglichkeiten, die als Indikatoren für eine Eventauslösung benutzt werden können:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Werte die durch einen (oder mehrere) POST-Parameter empfangen werden, die durch die &lt;STRONG&gt;&lt;A href="http://aspalliance.com/895"&gt;__doPostback-Javascriptfunktion&lt;/A&gt; abgeschickt werden&lt;/STRONG&gt; 
&lt;LI&gt;Zustandsänderungen aller Art auf der Serverseite (Datei, Datenbank, Session, Zeit, Datum, etc... 
&lt;LI&gt;Festgelegte Logik im Code, bspw. Vergleiche, etc... &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Aller Anfang ist &lt;STRIKE&gt;schwer&lt;/STRIKE&gt; leicht&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Zuerst folgt ein Beispiel das auf einen GET-Parameter reagiert und bei Vorhandensein des Parameters einen Event auslöst.&lt;/P&gt;
&lt;P&gt;C#:&lt;/P&gt;
&lt;DIV class=CodeBox&gt;
&lt;P&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;namespace&lt;/span&gt; pb.Web.UI.WebControls.Examples &lt;br /&gt;{ &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;class&lt;/span&gt; TestControlGetSimple : WebControl  &lt;br /&gt;    { &lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;event&lt;/span&gt; EventHandler ParameterAvailable; &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;virtual&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnParameterAvailable(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;object&lt;/span&gt; sender, EventArgs e) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.ParameterAvailable !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;) &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.ParameterAvailable(sender, e); &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; HtmlTextWriterTag TagKey { &lt;br /&gt;            get { &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; HtmlTextWriterTag.Div; &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnInit(EventArgs e) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.OnInit(e); &lt;br /&gt;&lt;br /&gt;            HyperLink link &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; HyperLink(); &lt;br /&gt;            link.ID &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"hlTest"&lt;/span&gt;; &lt;br /&gt;            link.Text &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"Testlink"&lt;/span&gt;; &lt;br /&gt;            link.NavigateUrl &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"?test=1234"&lt;/span&gt;; &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(link); &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnLoad(EventArgs e) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.OnLoad(e); &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; name &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Context.Request.QueryString[&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"test"&lt;/span&gt;]; &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt;(!&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt;.IsNullOrEmpty(name)) { &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.OnParameterAvailable(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;, EventArgs.Empty); &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;    } &lt;br /&gt;} &lt;/span&gt;&lt;/code&gt; &lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Was genau passiert da jetzt?&lt;/P&gt;
&lt;P&gt;Das Beispiel ist einfach aufgebaut. Zuerst wird ein Event mit einem Standard-Eventhandler (in .NET verfügbar) implementiert. &lt;BR&gt;Danach wird die eventauslösende On&lt;EM&gt;Event&lt;/EM&gt;-Methode definiert, die aufgerufen wird, wenn der Event ausgelöst werden soll.&lt;/P&gt;
&lt;P&gt;Anschliessend wird per überschriebenen &lt;A href="http://msdn.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.tagkey.aspx"&gt;TagKey-Eigenschaft&lt;/A&gt; angegeben, dass das Control ein umschliessenden Div-Tag besitzen soll. (Im Beispielprojekt wird das für die Formatierung benutzt). &lt;BR&gt;In der OnInit-Methode wird ein Objekt vom Typ Hyperlink angelegt, ein Text und eine Url + GET-Parameter angegeben und anschliessend zum Control hinzugefügt.&lt;/P&gt;
&lt;P&gt;Jetzt kommt der spannende Teil: Das Event wird ausgelöst.&lt;/P&gt;
&lt;P&gt;Beim Laden des Controls wird ein evt. vorhandener Parameter über &amp;lt;HttpContext&amp;gt;.Request.QueryString(&amp;lt;Key&amp;gt;) abgerufen, und anschliessend überprüft ob dieser &lt;EM&gt;null&lt;/EM&gt; oder ein &lt;EM&gt;Leerstring&lt;/EM&gt; (String.Empty) ist.&lt;/P&gt;
&lt;P&gt;Falls dies nicht der Fall ist, wird der Event ausgelöst. Das war schon der ganze "Zauber" auf der Control-Seite.&lt;/P&gt;
&lt;P&gt;Die Benutzung des Controls in einer ASP.NET Seite ist sehr einfach und geht so von der Hand, wie ansonsten ein Klick-Event eines Buttons abonniert wird.&lt;/P&gt;
&lt;P&gt;Wie das Control registiert wird, um auf der Seite zu benutzen, kann im folgendenen Blogpost nachgelesen werden:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.aspnetzone.de/blogs/peterbucher/archive/2007/09/27/usercontrol-und-customcontrols-per-web-config-verfuegbar-machen.aspx"&gt;UserControl und CustomControls per web.config verfuegbar machen&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Beispiel:&lt;/P&gt;
&lt;P&gt;ASPX: &lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;BR&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;fieldset&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;legend&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;gt;&lt;/span&gt;GET Beispiel (simple)&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;legend&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;pb:TestControlGetSimple&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;ID&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="testGetSimple"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;runat&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="server"&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;/&amp;gt;&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;br&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;/&amp;gt;&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;asp:Label&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;ID&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="lblInfoGetSimple"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Text&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="Parameter nicht verfügbar"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;runat&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="server"&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;/&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;fieldset&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;gt;&lt;/span&gt; &lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Codebehind (C#): &lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;object&lt;/span&gt; sender, EventArgs e) { &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.testGetSimple.ParameterAvailable += testGetSimple_ParameterAvailable; &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; testGetSimple_ParameterAvailable(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;object&lt;/span&gt; sender, EventArgs e) { &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.lblInfoGetSimple.Text &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"Parameter ist &amp;lt;strong&amp;gt;vorhanden&amp;lt;/strong&amp;gt;"&lt;/span&gt;; &lt;br /&gt;} &lt;/span&gt;&lt;/code&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Zuerst werden auf der ASP.NET Seite das Test-Control und ein Label hinzugefügt. &lt;BR&gt;Anschliessend abonnieren wir das Event im Page_Load Eventhandler und fügen dem zugewiesenen Handler Code hinzu, damit das Label anzeigt, ob der Event ausgelöst wurde oder nicht.&lt;/P&gt;
&lt;P&gt;Wenn der Link angeklickt wird und infolgedessen ein GET-Parameter vorhanden ist, wird das Event ausgelöst und im Eventhandler den Text des Labels geändert. &lt;BR&gt;Aus Benutzersicht ist nur der geänderte Text sichtbar.&lt;/P&gt;
&lt;P&gt;Das Beispiel wurde mit Absicht sehr simpel gehalten, um einen einfach Einstieg zu ermöglichen.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Ein erweitertes Beispiel mit GET-Parametern&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Folgend der Code eines erweiterten Beispiels, das mithilfe einer Session erkennen kann, ob der aktuelle Wert des GET-Parametes geändert wurde. Den ASPX-Teil wird nicht mehr gezeigt, da er praktisch identisch zum Beispiel (Siehe Code) ist.&lt;/P&gt;
&lt;P&gt;C#: &lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;namespace&lt;/span&gt; pb.Web.UI.WebControls.Examples &lt;br /&gt;{ &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;class&lt;/span&gt; TestControlGet : WebControl, INamingContainer &lt;br /&gt;    { &lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;delegate&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; NameChangedDelegate(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;object&lt;/span&gt; sender, NameChangedEventArgs e); &lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;event&lt;/span&gt; NameChangedDelegate NameChanged; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;virtual&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnNameChanged(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;object&lt;/span&gt; sender, NameChangedEventArgs e) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.NameChanged !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;) &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.NameChanged(sender, e); &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; HtmlTextWriterTag TagKey { &lt;br /&gt;            get { &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; HtmlTextWriterTag.Div; &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnInit(EventArgs e) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.OnInit(e); &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;for&lt;/span&gt; (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;int&lt;/span&gt; i &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; 0; i &amp;lt; 5; i++) { &lt;br /&gt;                HyperLink link &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; HyperLink(); &lt;br /&gt;                link.ID &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"testLink"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; i.ToString(); &lt;br /&gt;                link.Text &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"Patrick "&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; i.ToString(); &lt;br /&gt;                link.NavigateUrl &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"?name=Patrick"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; i.ToString(); &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(link); &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; LiteralControl(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"&amp;lt;br /&amp;gt;"&lt;/span&gt;)); &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnLoad(EventArgs e) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.OnLoad(e); &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; name &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Context.Request.QueryString[&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"name"&lt;/span&gt;]; &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; nameBefore; &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;object&lt;/span&gt; sessionValue &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Context.Session[&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"name"&lt;/span&gt;]; &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (sessionValue !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;) &lt;br /&gt;                nameBefore &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; sessionValue.ToString(); &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;bool&lt;/span&gt; flag &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;false&lt;/span&gt;; &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Green;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;// Erste Änderung (ohne Session, erster Aufruf) &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (name !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; sessionValue == &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;) &lt;br /&gt;                flag &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;true&lt;/span&gt;; &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Green;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;// Änderung mithilfe der Session herausfinden &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (sessionValue !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; name !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !sessionValue.Equals(name)) &lt;br /&gt;                flag &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;true&lt;/span&gt;; &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt;(flag) &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.OnNameChanged(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;, &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; NameChangedEventArgs(name)); &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Context.Session[&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"name"&lt;/span&gt;] &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; name; &lt;br /&gt;        } &lt;br /&gt;    } &lt;br /&gt;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;class&lt;/span&gt; NameChangedEventArgs : EventArgs { &lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;private&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; _newName; &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; NameChangedEventArgs(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; newName) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._newName &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; newName; &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; NewName { &lt;br /&gt;            get { &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._newName; } &lt;br /&gt;        } &lt;br /&gt;    } &lt;br /&gt;} &lt;/span&gt;&lt;/code&gt; &lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;In diesem Beispiel wird eine Liste von Links mit GET-Parametern ausgegeben. &lt;BR&gt;Wenn der empfangene Parameter ändert, wird der Event ausgelöst.&lt;/P&gt;
&lt;P&gt;Beim ersten Empfangen eines Wertes wird dieser in die Session geschrieben und dieser Spezialfall berücksichtigt. &lt;BR&gt;Wird jedoch ein Wert empfangen, wenn die Session schon ein Wert enthält, wird auf Ungleichheit geprüft, falls wahr wird der Event ausgelöst.&lt;/P&gt;
&lt;P&gt;Zudem wird in diesem Beispiel ein eigener Delegate benutzt, um eigene EventArgs zu unterstützen. &lt;BR&gt;Im Eventhandler kann der geänderte Namen einfach über &lt;STRONG&gt;e.NewName&lt;/STRONG&gt; abgerufen werden.&lt;/P&gt;
&lt;P&gt;(Der Einfachheit halber habe ich keinen generischen EventHandler benutzt, obwohl dieser ab .NET 2.0 natürlich zu empfehlen wäre. Wie es geht, siehe: &lt;A href="http://www.mycsharp.de/wbb2/thread.php?threadid=26116" target=_blank&gt;Eigenen Event definieren / Information zu Events (Externer Link: myCSharp.de)&lt;/A&gt; )&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Einen Event über POST-Werte mithilfe von &lt;A href="http://msdn.microsoft.com/de-de/library/system.web.ui.ipostbackeventhandler.aspx"&gt;IPostBackEventHandler&lt;/A&gt; und &lt;A href="http://msdn.microsoft.com/de-de/library/system.web.ui.clientscriptmanager.getpostbackeventreference.aspx"&gt;ClientScript.GetPostBackEventReference&lt;/A&gt; auslösen&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Wie weiter oben schon angesprochen, stellt ASP.NET selber eine Architektur bereit, um mit POST-Daten Events über eine spezielle Infrastruktur auszulösen. &lt;BR&gt;Die jetzt vorgestellte Lösung basiert auf der &lt;A href="http://aspalliance.com/895"&gt;__doPostBack-Funktion&lt;/A&gt;, die ASP.NET im Normalfall in jeder ASP.NET Seite zur Verfügung stellt.&lt;/P&gt;
&lt;P&gt;Folgend die Definition der Schnittstelle.&lt;/P&gt;
&lt;P&gt;C#: &lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;interface&lt;/span&gt; IPostBackEventHandler &lt;br /&gt;{ &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; RaisePostBackEvent(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; eventArgument); &lt;br /&gt;} &lt;/span&gt;&lt;/code&gt; &lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Im Normalfall geschieht ein Postback über einen Html-Button, der das Formular absendet. &lt;BR&gt;Das Formular kann aber auch per Javascript abgesendet werden, genau das nutzt die __doPostBack-Funktion. &lt;BR&gt;Sie kann zusätzlich Parameter entgegennehmen und diese über HiddenFields (Versteckte Eingabefelder) zum Server schicken.&lt;/P&gt;
&lt;P&gt;So ist nicht nur ein Abschicken und Prüfen von Form-Elementen möglich, sondern auch das übergeben beliebiger Elemente und zudem auch den Namen des Controls, von dem die Elemente bzw. Argumente kommen.&lt;/P&gt;
&lt;P&gt;Über die Methode &lt;EM&gt;GetPostBackEventReference()&lt;/EM&gt; der Klasse &lt;EM&gt;ClientScript&lt;/EM&gt; finden sich viele Überladungen, die benutzt werden können um eine Javascript Postback-Referenz zu bekommen. &lt;BR&gt;Dies ist nichts weiter als ein benutzerdefinierter Aufruf der __doPostBack-Funktion, mit eigenen Parametern.&lt;/P&gt;
&lt;P&gt;ASP.NET stellt eine Schnittstelle Namens &lt;EM&gt;IPostBackEventHandler&lt;/EM&gt; zur Verfügung, die implementiert werden kann, um über Postbacks mit der Möglichkeit der Übergabe von Elementen zu kommunizieren. &lt;BR&gt;Dabei muss immer das Control selber (schlussendlich die &lt;EM&gt;UniqueID&lt;/EM&gt; des Controls) übergeben werden, sowie Argumente nach Wunsch.&lt;/P&gt;
&lt;P&gt;Vielleicht kennt der eine oder andere die __doostBack-Funktion aus dem GridView, wenn eine Zeile selektiert wird. &lt;BR&gt;Dies wird genau nach diesem Schema erledigt.&lt;/P&gt;
&lt;P&gt;Folgend nun das Beispiel (Wiederum nur das Control an sich, da der Rest praktisch gleich ist):&lt;/P&gt;
&lt;P&gt;C#: &lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;namespace&lt;/span&gt; pb.Web.UI.WebControls.Examples &lt;br /&gt;{ &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;class&lt;/span&gt; TestControlPost : WebControl, INamingContainer, IPostBackEventHandler &lt;br /&gt;    { &lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;delegate&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; NameSelectedDelegate(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;object&lt;/span&gt; sender, NameSelectedEventArgs e); &lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;event&lt;/span&gt; NameSelectedDelegate NameSelected; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;virtual&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnNameChanged(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;object&lt;/span&gt; sender, NameSelectedEventArgs e) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.NameSelected !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;) &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.NameSelected(sender, e); &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; HtmlTextWriterTag TagKey { &lt;br /&gt;            get { &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; HtmlTextWriterTag.Div; &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnInit(EventArgs e) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.OnInit(e); &lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;for&lt;/span&gt; (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;int&lt;/span&gt; i &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; 0; i &amp;lt; 5; i++) { &lt;br /&gt;                HyperLink link &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; HyperLink(); &lt;br /&gt;                link.ID &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"testLink"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; i.ToString(); &lt;br /&gt;                link.Text &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"Patrick"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; i.ToString(); &lt;br /&gt;                link.NavigateUrl &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"#"&lt;/span&gt;; &lt;br /&gt;                link.Attributes.Add(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"onclick"&lt;/span&gt;, &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Page.ClientScript.GetPostBackEventReference(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;, &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"Patrick "&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; i.ToString())); &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(link); &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; LiteralControl(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"&amp;lt;br /&amp;gt;"&lt;/span&gt;)); &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;#region&lt;/span&gt; IPostBackEventHandler Members &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; RaisePostBackEvent(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; eventArgument) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt;(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.NameSelected !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;) &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.NameSelected(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;, &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; NameSelectedEventArgs(eventArgument)); &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;#endregion&lt;/span&gt; &lt;br /&gt;    } &lt;br /&gt;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;class&lt;/span&gt; NameSelectedEventArgs : EventArgs &lt;br /&gt;    { &lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;private&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; _selectedName; &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; NameSelectedEventArgs(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; newName) { &lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._selectedName &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; newName; &lt;br /&gt;        } &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; SelectedName { &lt;br /&gt;            get { &lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._selectedName; &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;    } &lt;br /&gt;} &lt;/span&gt;&lt;/code&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Das Beispiel ist dem letzten Beispiel sehr ähnlich, jedoch geht es hier um das Selektieren eines Namens, nicht um die Änderung dessen.&lt;/P&gt;
&lt;P&gt;Es werden auch HyperLinks erzeugt, und in dessen clientseitigem onclick-Eventhandler jeweils die PostBackEvent-Referenz mithilfe obengenannter Methode ein parameterisierter Javascript-Aufruf für das jeweilige Link erzeugt. &lt;BR&gt;Dabei wird eine Referenz auf das Control selbst mitgegeben, damit ASP.NET das Control anhand der UniqueID identifizieren kann, und den Namen, der selektiert werden kann.&lt;/P&gt;
&lt;P&gt;Die ASP.NET Engine merkt beim Durchgehen aller Controls, dass dieses Control die IPostBackEventHandler Schnittstelle implementiert und feuert dann ggf. bei Bestehen eines Events dass durch das Link gesendet wurde, das Event.&lt;/P&gt;
&lt;P&gt;Dies geschieht dadurch, dass ASP.NET die Methode RaisePostBackEvent aufruft und ihr das Argument übergibt, dass vom Client gesendet wurde. &lt;BR&gt;Aufgrund dieser Infos kann schlussendlich im Eventhandler auf das Argument zugegriffen werden.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Das Interface &lt;A href="http://msdn.microsoft.com/de-de/library/system.web.ui.ipostbackdatahandler.aspx"&gt;IPostBackDataHandler&lt;/A&gt;, Sinn und Nutzen&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;ASP.NET stellt noch ein weiteres Interface zur Verfügung, um Events auszulösen. &lt;BR&gt;Dieses setzt zwei Methoden voraus, folgend die Definition:&lt;/P&gt;
&lt;P&gt;C#: &lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;interface&lt;/span&gt; IPostBackDataHandler &lt;br /&gt;{ &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;bool&lt;/span&gt; LoadPostData(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; postDataKey, NameValueCollection postCollection); &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; RaisePostDataChangedEvent(); &lt;br /&gt;} &lt;/span&gt;&lt;/code&gt; &lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Im Beispiel auf der &lt;A href="http://msdn.microsoft.com/de-de/library/system.web.ui.ipostbackdatahandler.aspx"&gt;Seite&lt;/A&gt; von Microsoft, ist ein ziemlich sinnloses Beispiel zu finden, indem von einem WebControl ein Button nachgebaut wird.&lt;/P&gt;
&lt;P&gt;Diese Schnittstelle wird nur existieren, damit Microsoft alle Form-Controls implementieren konnte. &lt;BR&gt;In &lt;EM&gt;LoadPostData&lt;/EM&gt; werden die UniqueID des Controls selber und die komplette Post-Collection angeboten.&lt;/P&gt;
&lt;P&gt;Durch &lt;EM&gt;&amp;lt;Collection&amp;gt;[postDataKey]&lt;/EM&gt; kann der Wert des Controls sehr einfach gelesen werden, der Rückgabetyp ist ein &lt;EM&gt;bool&lt;/EM&gt; und bei einer Rückgabe von &lt;EM&gt;true&lt;/EM&gt; wird die &lt;EM&gt;RaisePostDataChangedEvent()-Methode&lt;/EM&gt; aufgerufen und der oder die Events können gefeuert werden. &lt;BR&gt;ASP.NET ruft - auch durch die Interface-Markierung - jeweils die Methode LoadPostData automatisch auf. &lt;BR&gt;Dies jedoch nur, wenn als &lt;EM&gt;TagKey&lt;/EM&gt; bzw &lt;EM&gt;TagName&lt;/EM&gt; des Controls ein bekanntes Form-Control gesetzt ist (Was auch Sinn macht). &lt;BR&gt;Wenn die Methode bei einem eigenen Control trotzdem aufgerufen werden soll, so muss die Methode &lt;A href="http://msdn.microsoft.com/de-de/library/system.web.ui.page.registerrequirespostback.aspx"&gt;RegisterRequiresPostBack&lt;/A&gt; (Siehe auch: &lt;A href="http://weblogs.asp.net/infinitiesloop/archive/2007/10/25/understanding-what-page-registerrequirespostback-does.aspx"&gt;Understanding what Page.RegisterRequiresPostBack does&lt;/A&gt;) von der Klasse &lt;A href="http://msdn.microsoft.com/de-de/library/system.web.ui.page.aspx"&gt;Page&lt;/A&gt; aufgerufen werden und das zu registrierende Control übergeben werden.&lt;/P&gt;
&lt;P&gt;Für eine Implementation der Controls: Button, DropDownList, TextBox, etc... ein sehr sinnvolles Interface. &lt;BR&gt;Bei der Implementation eines eigenen Controls, das kein Form-Tag darstellt geht es m.E. einfacher und besser ohne dieses Interface.&lt;/P&gt;
&lt;P&gt;Siehe auch:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A title=http://www.dotnetjunkies.com/WebLog/srivallichavalidotnet/archive/2005/11/14/133754.aspx href="http://www.dotnetjunkies.com/WebLog/srivallichavalidotnet/archive/2005/11/14/133754.aspx"&gt;http://www.dotnetjunkies.com/WebLog/srivallichavalidotnet/archive/2005/11/14/133754.aspx&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;An dieser Stelle gibt es kein Beispiel, jedoch ist im Download auch ein solches Beispiel vorhanden, dass das Interface benutzt.&lt;/P&gt;
&lt;P&gt;Inhalt des Downloads:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Alle hier darstellten Beispiele 
&lt;LI&gt;IPostBackDataHandler-Beispiel 
&lt;LI&gt;Alles in einer Solution mit einem Control-Library Projekt und einem Web Application Project zum Testen &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Download:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.aspnetzone.de/files/folders/197538/download.aspx"&gt;Control Events Sample&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Dank geht an&lt;/STRONG&gt;: &lt;BR&gt;&lt;A href="http://blog.norberteder.com/"&gt;Norbert Eder&lt;/A&gt; für das Review des Artikels&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Ich freue mich über jegliche Kommentare!&lt;/STRONG&gt;&lt;/P&gt;&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=197542" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control/default.aspx">Control</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/CustomControl/default.aspx">CustomControl</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/UniqueID/default.aspx">UniqueID</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/WebControl/default.aspx">WebControl</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/GET/default.aspx">GET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/IPostBackEventHandler/default.aspx">IPostBackEventHandler</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/EventHandler/default.aspx">EventHandler</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/POST/default.aspx">POST</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Events/default.aspx">Events</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/IPostBackDataHandler/default.aspx">IPostBackDataHandler</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/UserControl/default.aspx">UserControl</category></item><item><title>Artikel: StyleSwitcher selbst gemacht</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2008/05/28/artikel-styleswitcher-selbst-gemacht.aspx</link><pubDate>Wed, 28 May 2008 17:15:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:196715</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>4</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/196715.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=196715</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://www.aspnetzone.de/blogs/peterbucher/WindowsLiveWriter/ArtikelStyleSwitcherselbstgemacht_10EBD/asp0208-cover-300px_4.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH:0px;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height=244 alt=asp0208-cover-300px src="http://www.aspnetzone.de/blogs/peterbucher/WindowsLiveWriter/ArtikelStyleSwitcherselbstgemacht_10EBD/asp0208-cover-300px_thumb_1.jpg" width=174 border=0&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;In der aktuellen &lt;A href="http://www.aspnet-professional.de/"&gt;ASP.NET Professional&lt;/A&gt; 05/2008 Ausgabe&amp;nbsp; findet sich ein Artikel von mir über das &lt;A href="http://www.peterbucher.ch/projekte/styleswitcher.aspx"&gt;StyleSwitcher-Control&lt;/A&gt;. &lt;BR&gt;Im Artikel finden sich Informationen über das Innere des Controls, die Überlegungen dazu und die Implementation wird Schritt für Schritt erklärt.&lt;/P&gt;
&lt;P&gt;Wer kein Abonnement von ASP.NET Professional besitzt, trotzdem mal reinschnuppern möchte und meinen Artikel interessant findet, kann sich ein &lt;A href="http://www.aspnet-professional.de/freemag.aspx"&gt;kostenloses Probeabo&lt;/A&gt; zukommen lassen (Dort ist der aktuelle Artikel drin).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Der Artikel steht jetzt zum &lt;A href="http://www.aspnetzone.de/blogs/peterbucher/archive/2009/01/13/online-artikel-styleswitcher-selbst-gemacht.aspx"&gt;Download&lt;/A&gt; zur Verfügung.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Bearbeitungen / Korrekturen:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;13.01.09 - Downloadlink zum Online Artikel hinzugefügt&lt;/P&gt;&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=196715" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/StyleSwitcher/default.aspx">StyleSwitcher</category></item><item><title>Ein simples Listen Menü mit ASP.NET</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2008/04/01/ein-simples-listen-men-mit-asp-net.aspx</link><pubDate>Tue, 01 Apr 2008 17:18:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:194082</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>0</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/194082.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=194082</wfw:commentRss><description>&lt;IMG src="http://www.aspnetzone.de/photos/peterbucher/images/194080/original.aspx" align=right border=0&gt; 
&lt;P&gt;Das mitgelieferte Menü Control von ASP.NET rendert Tabellen und vieles unnötiges Markup.&lt;BR&gt;Mit den &lt;A href="http://www.google.ch/search?hl=de&amp;amp;q=css+adapters&amp;amp;meta="&gt;CSS Adapters&lt;/A&gt; wird das ganze zwar ausgebogen, erfordert aber eine Installation bzw. Einrichtung im Projekt und ist vielen (auch mir) nicht so symphatisch.&lt;/P&gt;
&lt;P&gt;Nicht nur aus oben genanntem Grund, sondern auch weil es eine suboptimale Lösung darstellt, der generierte Markup der Adapters ist m.E. auch noch nicht optimal.&lt;/P&gt;
&lt;P&gt;Ein Menü braucht ja jeder, und korrektes und einfaches Markup ist beim Menü noch viel wichtiger, als dies bei anderen Seitenteilen der Fall ist.&lt;BR&gt;Im Prinzip liefert ASP.NET schon ein &lt;STRIKE&gt;komplettes&lt;/STRIKE&gt; fast komplettes&amp;nbsp;Menü mit, ohne es danach zu Benennen ;-)&lt;/P&gt;
&lt;P&gt;Ich meine damit das "BulletedList" Control. Wenn dieses leicht abgeändert wird, wird daraus ein super funktionales Menü, das deklerativ, per Code&amp;nbsp;oder sogar per DataBinding mit Daten gefüllt werden kann.&lt;/P&gt;
&lt;P&gt;Natürlich hat dieses Control dann die Beschränkung auf eine Dimension, doch vielfach reicht dies aus.&lt;BR&gt;Ansonsten muss die ganze Gschicht dann auf einer anderen Basis aufgebaut werden.&lt;/P&gt;
&lt;P&gt;Genug der Worte, sehen wir uns den Code an...&lt;/P&gt;
&lt;P&gt;web.config (Beispiel siehe &lt;A href="http://www.aspnetzone.de/blogs/peterbucher/archive/2007/09/27/usercontrol-und-customcontrols-per-web-config-verfuegbar-machen.aspx"&gt;hier&lt;/A&gt;, geht aber auch in der Seite selber, für eine Seite):&lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;add&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;tagPrefix&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="pb"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;namespace&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="pb.Web.UI.WebControls"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;assembly&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="ListMenuTest"&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;ASPX:&lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;pb:ListMenu&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;ID&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="testMenu"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;runat&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="server"&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;asp:ListItem&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Text&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="Home"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Value&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="?url=1"&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;asp:ListItem&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Text&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="Produkte"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Value&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="?url=2"&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;asp:ListItem&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Text&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="Kontakt"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Value&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="?url=3"&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;asp:ListItem&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Text&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="FAQ"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Value&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="?url=4"&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;pb:ListMenu&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;Ein bisschen CSS:&lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; #testMenu {&lt;br /&gt; list-style-type: none;&lt;br /&gt; border: 1px dotted gray;&lt;br /&gt; padding: 15px;&lt;br /&gt; width: 200px;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#testMenu a {&lt;br /&gt;    font-family: Tahoma;&lt;br /&gt;    font-size: 1.5em;&lt;br /&gt;    font-style: oblique;&lt;br /&gt;    color: Black;&lt;br /&gt;    border-left: solid 20px #878787;&lt;br /&gt;    padding-left: 4px;&lt;br /&gt;    &lt;br /&gt;    text-decoration: none;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#testMenu a.active,&lt;br /&gt;#testMenu a:hover {&lt;br /&gt;    border-left: solid 20px #000446;&lt;br /&gt;    padding-left: 4px;&lt;br /&gt;    color: #878787;&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;Test Code für das Beispiel im Codebehind der Testseite:&lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;object&lt;/span&gt; sender, EventArgs e) {&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; activeValue &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Request.QueryString[&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"url"&lt;/span&gt;] &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;as&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (activeValue !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.testMenu.ActiveValue &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"?url="&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; activeValue;&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;Das Control selber:&lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System.Web.UI;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;namespace&lt;/span&gt; pb.Web.UI.WebControls&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;class&lt;/span&gt; ListMenu : BulletedList&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;private&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; _activeValue;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; ActiveValue {&lt;br /&gt;            get { &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._activeValue; }&lt;br /&gt;            set { &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._activeValue &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; value; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; RenderContents(HtmlTextWriter writer) {&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;foreach&lt;/span&gt; (ListItem item &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;in&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Items) {&lt;br /&gt;                writer.WriteFullBeginTag(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"li"&lt;/span&gt;);&lt;br /&gt;                writer.AddAttribute(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"href"&lt;/span&gt;, item.Value);&lt;br /&gt;                &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (item.Value == &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._activeValue) {&lt;br /&gt;                    writer.AddAttribute(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"class"&lt;/span&gt;, &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"active"&lt;/span&gt;);&lt;br /&gt;                }&lt;br /&gt;                writer.RenderBeginTag(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"a"&lt;/span&gt;);&lt;br /&gt;                writer.Write(item.Text);&lt;br /&gt;                writer.RenderEndTag();&lt;br /&gt;                writer.WriteEndTag(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"li"&lt;/span&gt;);&lt;br /&gt;                writer.Write(Environment.NewLine);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Wie man sehen kann, nehme ich das BulletedList Control, füge eine neue Eigenschaft "ActiveValue" hinzu und nehme das Rendering des Contents (Alle innenliegenden &amp;lt;li&amp;gt;-Tags) selber in die Hand.&lt;BR&gt;Hierbei wird dem aktiven Item jeweils die CSS Klasse "active" zugewiesen.&lt;/P&gt;
&lt;P&gt;Zuweisung der Styles erfolgt hier jetzt über die ID, die ID kann sich - &lt;A href="http://www.aspnetzone.de/blogs/peterbucher/archive/2007/04/09/artikel-identifizierung-von-controls-control-id-clientid-uniqueid.aspx"&gt;je nach Gegebenheit&lt;/A&gt;&amp;nbsp;- aber ändern, das heisst am besten eine Klasse dafür nehmen, oder über das umschliessende Div ansprechen.&lt;/P&gt;
&lt;P&gt;Thats it, viel&amp;nbsp;Spass damit!&lt;/P&gt;
&lt;P&gt;Beispielanwendung gibts hier zum &lt;A href="http://www.aspnetzone.de/files/folders/194084/download.aspx"&gt;Download&lt;/A&gt;&lt;/P&gt;&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=194082" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Tipps/default.aspx">Tipps</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/CustomControl/default.aspx">CustomControl</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Menu/default.aspx">Menu</category></item><item><title>UserControl und CustomControls per web.config verfuegbar machen</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2007/09/27/usercontrol-und-customcontrols-per-web-config-verfuegbar-machen.aspx</link><pubDate>Thu, 27 Sep 2007 17:55:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:185778</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>4</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/185778.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=185778</wfw:commentRss><description>In grösseren Projekten sammeln sich im optimalen Fall natürlich auch eine grosse Menge an Controls an. Diese müssen im Normallfall per Register Direktive in jeder ASPX Seite registriert und somit verfügbar gemacht werden. Es ist ab ASP.NET 2.0 aber auch...(&lt;a href="http://www.aspnetzone.de/blogs/peterbucher/archive/2007/09/27/usercontrol-und-customcontrols-per-web-config-verfuegbar-machen.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=185778" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/web_2E00_config/default.aspx">web.config</category></item><item><title>CheckBoxListValidator - CheckBoxList validieren</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2007/08/22/checkboxlistvalidator-checkboxlist-validieren.aspx</link><pubDate>Wed, 22 Aug 2007 21:57:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:184265</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>1</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/184265.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=184265</wfw:commentRss><description>Ich hatte neulich die Anforderung ein CheckBoxList Control zu validieren. Mit den Validatoren die mit ASP.NET mitkommen, lässt sich da nichts machen ausser dem Einkassieren einer Exception. Das ist auch gut so, denn diese sind nicht dafür gedacht. Es...(&lt;a href="http://www.aspnetzone.de/blogs/peterbucher/archive/2007/08/22/checkboxlistvalidator-checkboxlist-validieren.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=184265" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Validation/default.aspx">Validation</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/CheckBoxList/default.aspx">CheckBoxList</category></item><item><title>Ressourcen in CustomControl Assembly einbetten und benutzen</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2007/07/15/ressourcen-in-customcontrol-assembly-einbetten-und-benutzen.aspx</link><pubDate>Sun, 15 Jul 2007 21:54:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:182597</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>9</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/182597.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=182597</wfw:commentRss><description>&lt;P&gt;&lt;STRONG&gt;Einführung&lt;/STRONG&gt;&lt;BR&gt;Bei einem etwas umfangreicheren CustomControl kommt man schnell an die Grenzen.&lt;BR&gt;Es werden zusätzlich zu reinen Textausgaben, vielfach auch Ressourcen gebraucht,&lt;BR&gt;diese können in Form von Text sein, wie&amp;nbsp;z.B. Javascript oder CSS, aber auch binäre Daten, wie z.B. Bilder oder ZIP Dateien.&lt;/P&gt;
&lt;P&gt;Seit ASP.NET 2.0 gibt es die Möglichkeit, Ressourcen relativ einfach einzubinden, und zugleich in die Assembly mit zu kompilieren.&lt;BR&gt;Das heisst, die DLL für das Control enthält zugleich die Ressourcen die es benutzt.&lt;BR&gt;Das Deployment wird dadurch klarer und einfacher, die Ressourcen sind in der DLL gekapselt und können nicht einfach so ausgetauscht werden.&lt;BR&gt;Somit kann auch das Problem vermieden werden, eine andere Version der Ressource mitzuliefern.&lt;/P&gt;
&lt;P&gt;In ASP.NET 2.0 gibt es eine spezielle Url (WebResource.axd), die von der Engine genutzt wird, um dieses Feature umzusetzen.&lt;BR&gt;Über diese Url und zwei automatisch zugewiesenen Parametern (Assembly Key / DateTime of last Assembly write) kann die Ressource abgerufen und benutzt werden.&lt;BR&gt;Das ist vor allen Dingen für CSS und Javascript sehr interessant.&lt;BR&gt;Anstelle von Javascript Code der im Code eingebettet und per Page.ClientScript.RegisterClientScriptBlock() registriert wird, legen wir in unserem Projekt eine normale Javascript Datei an.&lt;BR&gt;Diese Datei wird als eingebettete Ressource markiert und dann per Code als externe Url in Empfang genommen.&lt;/P&gt;
&lt;P&gt;Die &lt;A href="http://www.webdevbros.net/2005/11/30/auto-resizing-textarea"&gt;Idee&lt;/A&gt; für das Beispielprojekt habe ich mir über zwei Ecken von &lt;A href="http://www.aspnetzone.de/members/gabru.aspx"&gt;Michal&lt;/A&gt; geholt, und den Javascript Code 1:1 übernommen.&lt;BR&gt;Es wird ein CustomControl implementiert, das sich selber bei Bedarf vergrössert und als Textarea gerendert wird.&lt;BR&gt;Damit haben wir nicht eine unnötig grosse Textarea auf der Seite, und den ganzen Text immer im Blickfeld.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Einbettung und Registrierung&amp;nbsp;der Ressource in die Assembly&lt;BR&gt;&lt;/STRONG&gt;Eine Ressource (z.B. Javascript oder CSS) kann direkt als Datei in das CustomControl Projekt eingefügt werden.&lt;BR&gt;Im Beispielprojekt erstellen wir eine Javascript Datei im Solution Explorer und markieren diese als &lt;STRONG&gt;eingebettete Ressource&lt;/STRONG&gt;.&lt;BR&gt;Dies bewirkt dass die Ressource beim kompilieren in die resultierende DLL eingebettet wird.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.aspnetzone.de/photos/peterbucher/images/182595/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;Die Ressource muss in der AssemblyInfo.cs registriert werden, damit wir über den Webresource.axd HTTP Handler darauf zugreifen können.&lt;BR&gt;Unter "Properties" im Solution Explorer und dem betreffenden Projekt, liegt die AssemblyInfo.cs, in dieser müssen wir ein zusätzliches Attribut&amp;nbsp;nach folgender Konvention&amp;nbsp;hinzufügen.&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;[assembly: WebResource(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"&amp;lt;Root Namespace&amp;gt;.&amp;lt;Dateipfad&amp;gt;"&lt;/span&gt;, &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"&amp;lt;ContentType&amp;gt;"&lt;/span&gt;)]&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Im Falle des Beispielprojekts ergibt sich folgendes Attribut:&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;[assembly: WebResource(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"t4m.Controls.AutoResizingTextarea.js"&lt;/span&gt;, &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"text/javascript"&lt;/span&gt;)]&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In VB.NET gibt es die Option einen "Rootnamespace" bzw. "Stamm Namespace" anzugeben, oder auch nicht.&lt;BR&gt;Wenn dieser leer ist, darf _nur_ der Dateiname der Ressource angegeben werden.&lt;/P&gt;
&lt;P&gt;Andernfalls [Stamm Namespace].[Dateiname]&lt;/P&gt;
&lt;P&gt;VB.NET kann nicht mit Pfaden umgehen, daher müssen alle Ressourcen jeweils einen anderen Dateinamen in derselben Assembly haben,&lt;BR&gt;ansonsten wird die Assembly nicht erstellt.&lt;/P&gt;
&lt;P&gt;Zitat aus (&lt;A href="http://www.codeproject.com/KB/aspnet/MyWebResourceProj.aspx"&gt;CodeProject Artikel [Kommentar]&lt;/A&gt;):&lt;BR&gt;
&lt;DIV class=Quotes&gt;c# way: &lt;BR&gt;[Default namespace].[PathToTheResource].[ResourceName]
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;vb.net way:&lt;BR&gt;If you have empty namespace: [ResourceName] Nothing more nothing less!!!&lt;BR&gt;You have a given root namespace: [Default namespace].[ResourceName] No path at all!!!&lt;/P&gt;
&lt;P&gt;So vb.net doesn't (cannot?) use the path, this means: if you have two resource with same name in different place in your solution the project won't build!&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Eine Angabe in VB.NET kann in der Controlklasse erfolgen, sowie auch in der AssemblyInfo.vb.&lt;BR&gt;Beides funktioniert, allerdings wäre der Weg über die AssemblyInfo.vb wohl sauberer.&lt;BR&gt;Ein solches Attribut kann folgendermassen aussehen:&lt;/P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;Assembly&lt;/span&gt;: WebResource(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"MeineRessource.js"&lt;/span&gt;, &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"text/javascript"&lt;/span&gt;)&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;(Damit die AssemblyInfo.vb sichtbar wird, muss im Solution Explorer die Option "Alle Dateien anzeigen" gewählt werden!)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Benutzung der Ressource im CustomControl&lt;/STRONG&gt;&lt;BR&gt;Über die ClientScriptManager Instanz und dessen Methode "GetWebResourceUrl" kann die Url zur Ressource abgerufen werden.&lt;BR&gt;Mit der Methode "RegisterClientScriptInclude" des ClientScriptManagers und der Url wird die Ressource als externes Javascript eingebunden, und ist somit auf der aktuellen Seite verfügbar.&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;In der überschriebenen Methode "AddAttributesToRender" hängen wir ein "onkeyup" Eventhandler mit einem parameterisierten Funktionsaufruf als Attribut für die Textarea&amp;nbsp;hinzu.&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; AddAttributesToRender(HtmlTextWriter writer)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; attributeString &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; String.Empty;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;bool&lt;/span&gt; addAttributes &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;true&lt;/span&gt;;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt;(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._minRows !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; 0 &amp;amp;&amp;amp; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._minCols !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; 0) {&lt;br /&gt;        &lt;span style="color: Green;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;// Zeilen und Spalten resizen&lt;/span&gt;&lt;br /&gt;        attributeString &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"resizeTextArea(this, "&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._minCols.ToString() &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;", "&lt;/span&gt;&lt;br /&gt;                          &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._minRows.ToString() &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;");"&lt;/span&gt;;&lt;br /&gt;    } &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;else&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt;(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._minCols !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; 0) {&lt;br /&gt;        &lt;span style="color: Green;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;// Nur Zeilen resizen&lt;/span&gt;&lt;br /&gt;        attributeString &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"resizeTextArea(this, "&lt;/span&gt;&lt;br /&gt;                          &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._minCols.ToString() &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;");"&lt;/span&gt;;&lt;br /&gt;    } &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;else&lt;/span&gt; {&lt;br /&gt;        addAttributes &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;false&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt;(addAttributes)&lt;br /&gt;        writer.AddAttribute(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"onkeyup"&lt;/span&gt;, attributeString);&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.AddAttributesToRender(writer);&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Im überschriebenen OnPreRender des Controls wird das Include per ClientScriptManager registriert.&lt;BR&gt;Die Methode "RegisterClientScriptInclude" erwartet einen Schlüssel und die Url der Resource.&lt;BR&gt;Die Parameter der "GetWebResourceUrl" Methode sind jeweils der Typ der Assembly und den Ressourcennamen (der selbe wie in AssemblyInfo.cs).&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnPreRender(EventArgs e)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Page !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;        ClientScriptManager manager &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Page.ClientScript;&lt;br /&gt;        manager.RegisterClientScriptInclude(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"AutoResizingTextArea"&lt;/span&gt;,&lt;br /&gt;                                            manager.GetWebResourceUrl(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.GetType(),&lt;br /&gt;                                                                      &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"t4m.Controls.AutoResizingTextarea.js"&lt;/span&gt;));&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.OnPreRender(e);&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mithilfe der "RegisterClientScriptInclude" Methode wird der Javascript Include Tag nur einmal und inmitten der Seite bzw. genau oberhalb des ersten Controls gerendert.&lt;BR&gt;Das ist ein wenig unschön. Das Include kann aber&amp;nbsp;auch in den Head Tag gerendert werden, jedoch in Eigenregie.&lt;BR&gt;Über die ID und vorangehende Prüfung auf ein Control in der Hierarchie wird vermieden, dass das Include bei mehr als einem&amp;nbsp;Control des gleichen Typs&amp;nbsp;mehrfach gerendert wird.&lt;BR&gt;Diese Überprüfungsarbeit wird uns im oberen Fall mit "RegisterClientScriptInclude" abgenommen, aber die Prüfung auf die ID ist nicht aufwändig und funktioniert.&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Page.FindControl(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"AutoResizingTextArea"&lt;/span&gt;) == &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; jsUrl &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Page.ClientScript.GetWebResourceUrl(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.GetType(), &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"t4m.Controls.AutoResizingTextarea.js"&lt;/span&gt;);&lt;br /&gt;    HtmlGenericControl link &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; HtmlGenericControl(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"script"&lt;/span&gt;);&lt;br /&gt;    link.ID &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"AutoResizingTextArea"&lt;/span&gt;;&lt;br /&gt;    link.Attributes.Add(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"type"&lt;/span&gt;, &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"text/javascript"&lt;/span&gt;);&lt;br /&gt;    link.Attributes.Add(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"src"&lt;/span&gt;, jsUrl);&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Page.Header.Controls.Add(link);&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt; 
&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Die Ausgabe des Javascript Includes sieht dann z.B. so aus:&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: Maroon;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;script&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;src&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="http://www.aspnetzone.de/WebResource.axd?d=mKz7Vb-Q8_bkDUZyl5AYY8EyVDVf_p6szFgppsuGhxxVgB7LsNffB2soCdnTCu7p8Y2KMjUlABwuU4ycvynCQw2&amp;amp;amp;t=633201523485135647"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;type&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;="text/javascript"&lt;/span&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Quellen und weiterführende Links:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://aspnet.4guysfromrolla.com/articles/080906-1.aspx"&gt;Accessing Embedded Resources through a URL using WebResource.axd&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://support.microsoft.com/kb/910442/de"&gt;Arbeiten mit Web Resources in ASP.NET 2.0&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.addattributestorender(VS.80).aspx"&gt;WebControl.AddAttributesToRender-Methode (System.Web.UI.WebControls)&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.clientscriptmanager(vs.80).aspx"&gt;ClientScriptManager-Klasse&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Beispielprojekt:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.aspnetzone.de/files/folders/182596/download.aspx"&gt;EmbeddedResourcesTest&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Bearbeitung / Korrekturen&lt;/STRONG&gt;:&lt;BR&gt;26.06.08 - Update für VB.NET&lt;/P&gt;&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=182597" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Javascript/default.aspx">Javascript</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/CustomControl/default.aspx">CustomControl</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/WebResource.axd/default.aspx">WebResource.axd</category></item><item><title>SelfValidatingControl - CustomControl selber validieren lassen</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2007/06/22/selfvalidatingcontrol-customcontrol-selber-validieren-lassen.aspx</link><pubDate>Thu, 21 Jun 2007 22:24:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:181613</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>1</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/181613.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=181613</wfw:commentRss><description>&lt;P&gt;Ich bin in der &lt;A href="http://groups.google.ch/group/microsoft.public.de.german.entwickler.dotnet.asp/topics?hl=de"&gt;Newsgroup&lt;/A&gt; über die &lt;A href="http://groups.google.ch/group/microsoft.public.de.german.entwickler.dotnet.asp/browse_thread/thread/b504a2ee2c4134c7/c77ea83679f6e117?hl=de#c77ea83679f6e117"&gt;Frage&lt;/A&gt; gestolpert, wie man ein sich selbst validierendes Control, ohne ein zusätzliches Custom Validator Control dazu bringen kann, die Eigenschaft &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.page.isvalid(VS.80).aspx"&gt;IsValid&lt;/A&gt; von der aktuellen Page Instanz zu beeinflussen.&lt;/P&gt;
&lt;P&gt;Nun, wenn man ein bisschen nachforscht, findet man in der MSDN oder aber dem &lt;A href="http://www.aisto.com/roeder/dotnet/"&gt;Reflector&lt;/A&gt; die abstrakte Basisklasse &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.basevalidator(VS.80).aspx"&gt;BaseValidator&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Folgend die Definition dieser Basisklasse:&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;abstract&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;class&lt;/span&gt; BaseValidator : Label, IValidator&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eine Klasse die von BaseValidator erbt, so wie das bei allen Validator Controls ausser der &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.validationsummary(VS.80).aspx"&gt;ValiationSummary&lt;/A&gt; der Fall ist, erben also von &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.label(VS.80).aspx"&gt;Label&lt;/A&gt; und implementieren das Interface &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.ivalidator(VS.80).aspx"&gt;IValidator&lt;/A&gt;.&lt;BR&gt;Okay, für einen Validator an sich, mag es sinnvoll sein, sich wie ein Label zu verhalten, denn wir wollen schliesslich eine Fehlermeldung ausgeben.&lt;BR&gt;In einem CustomControl sieht das aber wieder anders aus, vorallem dann, wenn wir die Validation selber erledigen.&lt;/P&gt;
&lt;P&gt;Man kann / könnte die benötigten und schon im Framework vorhandenen Validatoren zu seinem CustomControl hinzufügen, und schliesslich auch veranlassen, dass diese Validatoren bei der Seitenüberprüfung berücksichtigt werden.&lt;BR&gt;Jedoch geht es m.E. leichter von der Hand, wenn man sein CustomControl validationsfähig macht, und die einzelnen Prüfungen, sowie auch die Fehlerausgabe im Control selber erledigt.&lt;/P&gt;
&lt;P&gt;Ich möchte euch anhand eines einfachen uns ziemlich sinnfreien Beispiels zeigen, wie man so etwas implementieren könnte.&lt;BR&gt;Eine Klasse das als Validator fungieren möchte, muss das Interface (Schnittstelle) &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.ivalidator(VS.80).aspx"&gt;IValidator&lt;/A&gt; implementieren, als Basisklasse wählen wir in diesem Fall &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.control(VS.80).aspx"&gt;Control&lt;/A&gt;, da wir kein einzelnes Haupt Element brauchen.&lt;BR&gt;Definition unseres CustomControls:&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;class&lt;/span&gt; SelfValidatingControl : Control, IValidator&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;
&lt;P&gt;
&lt;P&gt;Als nächstes definieren wir die benötigten privaten Felder.&lt;BR&gt;_isValid brauchen wir als Hilfsvariable im Zusammenspiel mit der Validierung.&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;private&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;bool&lt;/span&gt;    _isValid &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;private&lt;/span&gt; TextBox _txtSurname;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;private&lt;/span&gt; TextBox _txtName;&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;
&lt;P&gt;
&lt;P&gt;Und jetzt geht es an die Implementation des CustomControls, hierzu erstellen wir im&amp;nbsp;Konstruktor&amp;nbsp;zwei TextBoxen und fügen sie zur Controls Collection hinzu.&lt;BR&gt;Zwischen die TextBoxen schieben der Einfachheit halber, LiteralControls, jeweils mit "Vorname", "Name" und den dazugehörigen Breaks dazu "&amp;lt;br /&amp;gt;".&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; SelfValidatingControl() {&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._txtSurname &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; TextBox();&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._txtName    &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; TextBox();&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; LiteralControl(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"Vorname:"&lt;/span&gt;));&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; LiteralControl(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"&amp;lt;br /&amp;gt;"&lt;/span&gt;));&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._txtSurname);&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; LiteralControl(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"&amp;lt;br /&amp;gt;"&lt;/span&gt;));&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; LiteralControl(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"Name:"&lt;/span&gt;));&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;new&lt;/span&gt; LiteralControl(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"&amp;lt;br /&amp;gt;"&lt;/span&gt;));&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._txtName);&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jetzt fehlen noch zwei wichtige Dinge:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Implementation der IValidator Schnittstelle 
&lt;LI&gt;Weitergabe des Validators an die Validator Collection der aktuellen Page Instanz&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Wenn wir die Schnittselle in der Klassendefinition niederschreiben, gibt uns Visual Studio die Möglichkeit, automatisch ein Grundgerüst für diese Schnittstelle zu erstellen. Nette Sache, machen wir :-)&lt;BR&gt;Die Eigenschaft "ErrorMessage" müssen wir implementieren, benutzen sie in diesem Fall aber nicht, deshalb ist auch der Setter leer.&lt;BR&gt;Bei der Eigenschaft "IsValid", geben wir den aktuellen Status anhand der Instanzvariable "_isValid" zurück, oder ändern diese.&lt;BR&gt;In der Validate Methode, wird die Validierung ausgeführt, und die Instanzvariable "_isValid" bei Erfolg auf true, und bei Misserfolg auf false gesetzt.&lt;BR&gt;Im konkreten Fall überprüfen wir nur, ob beide TextBoxen nicht leer sind, thats it.&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;#region&lt;/span&gt; IValidator Members &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; ErrorMessage&lt;br /&gt;{&lt;br /&gt;    get&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"Surname or Name empty"&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;    set { ; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;bool&lt;/span&gt; IsValid&lt;br /&gt;{&lt;br /&gt;    get&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._isValid;&lt;br /&gt;    }&lt;br /&gt;    set&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._isValid &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; value;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; Validate()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._txtSurname.Text !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; String.Empty&lt;br /&gt;       &amp;amp;&amp;amp;&lt;br /&gt;       &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._txtName.Text !&lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; String.Empty)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._isValid &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;true&lt;/span&gt;;&lt;br /&gt;    } &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;else&lt;/span&gt; {&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._isValid &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;false&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;#endregion&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Und jetzt kommt der ganze Clou an der Sache.&lt;BR&gt;Wenn wir auf der aktuellen Page den Status per Page.IsValid abfragen, durchläuft die aktuelle Page Instanz ihre Validator Collection.&lt;BR&gt;Unser Control muss dort jetzt natürlich rein, da es, ausser einem Control, zusätzlich auch noch die Rolle eines Validators eingenommen hat.&lt;BR&gt;Dies erledigen wir, indem wir die OnInit Methode des Controls überschreiben und dort auf die aktuelle Page Instanz Zugreifen.&lt;BR&gt;Über die .Add Methode der Validator Collection, fügen wir über "this", die aktuelle Instanz unserer Control Klasse hinzu, also das Objekt, in dem wir uns im Moment befinden.&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; OnInit(EventArgs e)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.OnInit(e);&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.Page.Validators.Add(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;);&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Auf der einer beliebigen Seite müssen wir nur noch unser Control deklerativ oder per Code einfügen.&lt;BR&gt;Ab diesem Moment ist die Page.IsValid Eigenschaft auch auf den Zustand dieses Controls sensibel.&lt;/P&gt;
&lt;P&gt;Beispielprojekt:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.aspnetzone.de/files/folders/181614/download.aspx"&gt;SelfValidatingControlTest&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Quellen:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/library/deu/default.asp?url=/library/DEU/cpguide/html/cpconsupportingup-levelbrowsers.asp"&gt;Entwickeln eines Bestätigungssteuerelements (MSDN)&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=181613" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control/default.aspx">Control</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/CustomControl/default.aspx">CustomControl</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/IValidator/default.aspx">IValidator</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Page.Validators/default.aspx">Page.Validators</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/BaseValidator/default.aspx">BaseValidator</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Validation/default.aspx">Validation</category></item><item><title>Von WebControl abgeleitetes CustomControl - Haupt Html Element festlegen</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2007/05/31/von-webcontrol-abgeleitetes-customcontrol-haupt-html-element-festlegen.aspx</link><pubDate>Thu, 31 May 2007 21:59:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:180612</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>3</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/180612.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=180612</wfw:commentRss><description>&lt;P&gt;Wenn man ein CustomControl mit ASP.NET entwickeln will, leitet man in den meisten Fällen von WebControl ab.&lt;/P&gt;
&lt;P&gt;Zitat aus einem MSDN Artikel:&amp;nbsp;&lt;A href="http://msdn2.microsoft.com/de-de/library/yhzc935f(VS.80).aspx"&gt;Entwickeln und Verwenden eines benutzerdefinierten Serversteuerelements&lt;/A&gt; 
&lt;DIV class=Quotes&gt;Wenn das Steuerelement ein Element der Benutzeroberfläche (UI) oder ein anderes auf dem Client sichtbares Element rendert, sollten Sie das Steuerelement von &lt;B&gt;System.Web.UI.WebControls.WebControl&lt;/B&gt; (oder einer davon abgeleiteten Klasse) ableiten. Falls das Steuerelement ein Element rendert, das im Clientbrowser nicht sichtbar ist, z.&amp;nbsp;B. ein ausgeblendetes Element oder ein &lt;B&gt;meta&lt;/B&gt;-Element, leiten Sie das Steuerelement von &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.control(VS.80).aspx"&gt;System.Web.UI.Control&lt;/A&gt; ab. Die &lt;B&gt;WebControl&lt;/B&gt;-Klasse ist von &lt;B&gt;Control&lt;/B&gt; abgeleitet und fügt formatbezogene Eigenschaften hinzu, z.&amp;nbsp;B. &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.font(VS.80).aspx"&gt;Font&lt;/A&gt;, &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.forecolor(VS.80).aspx"&gt;ForeColor&lt;/A&gt; und &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.backcolor(VS.80).aspx"&gt;BackColor&lt;/A&gt;. Zusätzlich kann ein von &lt;B&gt;WebControl&lt;/B&gt; abgeleitetes Steuerelement die Designfeatures von ASP.NET nutzen, ohne dass für Sie zusätzliche Arbeit entsteht. 
&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Standardmässig wird bei einer Ableitung von WebControl ein Span-Tag als Hauptelement gerendert, dieses Element enthält unter anderem die ClientID des Controls als ID-Attribut.&lt;BR&gt;In den meisten Fällen möchten wir einen anderen Tag als Grundlage verwenden, bspw. einen Div-Tag.&lt;/P&gt;
&lt;P&gt;Erklären lässt sich dieses Verhalten, wenn wir einen Blick auf die Implementierung von der Klasse WebControl werfen.&lt;BR&gt;Der Standardkonstruktor ruft den zweiten Konstruktor auf, und übergibt diesem ein &lt;A href="http://msdn.microsoft.com/library/deu/default.asp?url=/library/DEU/cpref/html/frlrfsystemwebuihtmltextwritertagclasstopic.asp"&gt;HtmlTextWriterTag&lt;/A&gt;.Span mit:&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt; &lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; WebControl() : &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;(HtmlTextWriterTag.Span)&lt;br /&gt;{&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt; 
&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Für diesen Fall habe ich im Internet ein "Workaround" gefunden, bei dem man die Methoden &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.renderbegintag(VS.80).aspx"&gt;RenderBeginTag()&lt;/A&gt; und &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.renderendtag(vs.80).aspx"&gt;RenderEndTag()&lt;/A&gt; überschreibt.&lt;BR&gt;Das Haupt Html Element&amp;nbsp;rendert man inklusive der Unterelemente&amp;nbsp;dann in einer überschriebenen &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.render(vs.80).aspx"&gt;Render()&lt;/A&gt; Methode.&lt;/P&gt;
&lt;P&gt;Das sieht dann so aus:&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; RenderBeginTag(HtmlTextWriter writer) {&lt;br /&gt;   &lt;span style="color: Green;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;// do nothing&lt;/span&gt;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; RenderEndTag(HtmlTextWriter writer) {&lt;br /&gt;   &lt;span style="color: Green;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;// do nothing&lt;/span&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Diese Sache funktioniert auch wunderbar, jedoch hat das auch ein paar Nachteile bzw. die nächste Variante, Vorteile.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Wir nutzen eine eigene Konstruktion, nicht die bequemen Vorgaben von &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol(vs.80).aspx"&gt;WebControl&lt;/A&gt; 
&lt;LI&gt;Die Methoden &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.addattributestorender(vs.80).aspx"&gt;AddAttributesToRender()&lt;/A&gt;, RenderBeginTag(), RenderContents() und RenderEndTag() werden überflüssig und nicht mehr nutzbar 
&lt;LI&gt;Es muss mehr geschrieben werden, obwohl es einfacher gehen würde&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Intern sieht die Render() Methode von WebControl, die wir ansonsten ja überschreiben, ungefähr so aus:&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;internal&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; Render(HtmlTextWriter writer)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.RenderBeginTag(writer);&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.RenderContents(writer);&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.RenderEndTag(writer);&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt; 
&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Das heisst, wenn das Control mit Render() gerendert wird, werden diese drei Methoden hintereinander aufgerufen.&lt;BR&gt;Diese Aufrufe passieren automatisch, darum müssen wir uns nicht kümmern, so ist es natürlich bequem zu handhaben.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Erstellen einer Klasse die von WebControl abgeleitet ist 
&lt;LI&gt;Im Konstruktor den Basis Konstruktor aufrufen und einen TagNamen für das Control mitgeben 
&lt;LI&gt;AddAttributesToRender() Methode überschreiben und mit unseren Attributen füllen 
&lt;LI&gt;Die RenderContents() Methode überschreiben und unsere Inhalte rendern lassen&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Wie man sieht, ist hier ein schöner Ablauf in Methoden und Methodenaufrufen gegliedert.&lt;BR&gt;Der eigentliche Clou liegt darin, den HtmlWriterTag Enumerationswert im Basiskonstruktor mitzugeben.&lt;BR&gt;Um einen Div Tag als Haupt Html Element für sein Control möchte, kann dieser Konstruktor so aussehen:&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Green;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;// Möglichkeit 1, HtmlTextWriterTag Enum Wert übergeben&lt;/span&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; MyControl() : &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;(HtmlTextWriterTag.Div) {&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: Green;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;// Möglichkeit 2, String übergeben&lt;/span&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; MyControl() : &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"div"&lt;/span&gt;) {&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt; 
&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Die zweite Möglichkeit kann man für Tags nutzen, die nicht in der Enumeration vorhanden sind.&lt;BR&gt;Wenn man AddAttributesToRender() überschreibt, kann man Attribute an das Haupt Html Element hängen.&lt;BR&gt;Das kann z.B. ein onclick Attribute sein:&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; AddAttributesToRender(HtmlTextWriter writer) {&lt;br /&gt;   writer.AddAttribute(HtmlTextWriterAttribute.Onclick, &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"alert('Klappt :-)');"&lt;/span&gt;);&lt;br /&gt;   &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.AddAttributesToRender(writer);&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt; 
&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;In &lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.rendercontents(vs.80).aspx"&gt;RenderContents()&lt;/A&gt; rendern wir den Inhalt, und fertig ist unser Render Grundgerüst für das CustomControl.&lt;/P&gt;
&lt;P&gt;Fazit:&lt;BR&gt;Wie man sieht, bietet ASP.NET ein super Modell, um die Entwicklung von Controls&amp;nbsp;zu erleichtern. Das Modell ist m.E. logisch und verständlich aufgebaut.&lt;BR&gt;Um das Modell dahinter noch besser zu verstehen, sollte man die .NET Implementation&amp;nbsp;mit&amp;nbsp;dem &lt;A href="http://www.aisto.com/roeder/dotnet/"&gt;Lutz Roeders .NET Reflector&lt;/A&gt; genauer anschauen, heisser Tipp! :-)&lt;/P&gt;
&lt;P&gt;Ein Codebeispiel folgt...&lt;/P&gt;&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=180612" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Tipps/default.aspx">Tipps</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/CustomControl/default.aspx">CustomControl</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category></item><item><title>WaitButtonControl - Auf langes Postback warten</title><link>http://www.aspnetzone.de/blogs/peterbucher/archive/2007/05/31/waitbuttoncontrol-auf-langes-postback-warten.aspx</link><pubDate>Thu, 31 May 2007 21:56:00 GMT</pubDate><guid isPermaLink="false">ce930855-ae9b-4fa4-8077-06a76071cc6a:180624</guid><dc:creator>Peter Bucher</dc:creator><slash:comments>1</slash:comments><comments>http://www.aspnetzone.de/blogs/peterbucher/comments/180624.aspx</comments><wfw:commentRss>http://www.aspnetzone.de/blogs/peterbucher/commentrss.aspx?PostID=180624</wfw:commentRss><description>&lt;IMG src="http://www.aspnetzone.de/photos/peterbucher/images/180625/original.aspx" align=right border=0&gt; 
&lt;P&gt;Wieder einmal (wie immer :-), wurde ich durch eine &lt;A href="http://www.mycsharp.de/wbb2/thread.php?postid=202824"&gt;Frage&lt;/A&gt; im Forum angeregt.&lt;BR&gt;Es ging darum, einen Button zu haben, der nach dem Klicken sofort deaktiviert wird, einen Hinweistext darstellt und trotzdem noch ein normales PostBack inkl.&amp;nbsp;"Absenderadresse"&amp;nbsp;versendet.&lt;/P&gt;
&lt;P&gt;Die Lösung war am Ende folgende (Im Page_Load bspw.):&lt;BR&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;.&amp;lt;Button&amp;gt;.Attributes.Add(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"onclick"&lt;/span&gt;, &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"this.disabled = true; this.value = 'Bitte warten...'; "&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt; ClientScript.GetPostBackEventReference(&amp;lt;Button&amp;gt;, &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;));&lt;/span&gt;&lt;/code&gt; 
&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Nun gut, es funktioniert, ist relativ schnell geschrieben - aber:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Man muss es trotzdem immer wieder schreiben 
&lt;LI&gt;Es ist schlussendlich Code, der das Gesamtbild aufbläht 
&lt;LI&gt;Wenn man eine zusätzliche Funktionalität möchte, muss man es überall nachtragen 
&lt;LI&gt;Schlussendlich endet das in der Copy&amp;amp;Paste Hell ;-)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Genau für so etwas ist ein ASP.NET CustomControl sehr gut geeignet.&lt;BR&gt;Es folgt der Quellcode des Controls und ein Beispiel zum Herunterladen und Probieren.&lt;/P&gt;&lt;STRONG&gt;WaitButton.cs&lt;/STRONG&gt; 
&lt;P&gt;
&lt;DIV class=CodeBox&gt;&lt;code&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System.Web;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System.Web.UI;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;using&lt;/span&gt; System.ComponentModel; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;namespace&lt;/span&gt; t4m.Controls&lt;br /&gt;{&lt;br /&gt;    [DefaultProperty(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"WaitText"&lt;/span&gt;)]&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;class&lt;/span&gt; WaitButton : Button&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;private&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;const&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; DefaultWaitText &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"Bitte warten..."&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;private&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;bool&lt;/span&gt; _wait       &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;true&lt;/span&gt;;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;private&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; _waitText &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; DefaultWaitText;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;bool&lt;/span&gt; Wait {&lt;br /&gt;            get { &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._wait; }&lt;br /&gt;            set { &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._wait &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; value; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;public&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;string&lt;/span&gt; WaitText {&lt;br /&gt;            get { &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;return&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._waitText; }&lt;br /&gt;            set { &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._waitText &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;=&lt;/span&gt; value; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;override&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;void&lt;/span&gt; AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;if&lt;/span&gt; (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._wait)&lt;br /&gt;                writer.AddAttribute(&lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"onclick"&lt;/span&gt;,&lt;br /&gt;                    &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"this.disabled = true;"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt;&lt;br /&gt;                    &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"this.value    = '"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt;&lt;br /&gt;                    (&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._waitText == DefaultWaitText ? DefaultWaitText : &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;._waitText) &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt;&lt;br /&gt;                    &lt;span style="color: #666666;background-color: #e4e4e4;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;"';"&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;+&lt;/span&gt;&lt;br /&gt;                    Page.ClientScript.GetPostBackEventReference(&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;this&lt;/span&gt;, &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;null&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 14px;font-weight: normal;"&gt;base&lt;/span&gt;.AddAttributesToRender(writer);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Beispielprojekt:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.aspnetzone.de/files/folders/180626/download.aspx"&gt;WaitButton Test Projekt&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Weiterführende Links:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.webcontrols.webcontrol.addattributestorender(VS.80).aspx"&gt;WebControl.AddAttributesToRender-Methode&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/de-de/library/system.web.ui.page.getpostbackeventreference(vs.80).aspx"&gt;Page.GetPostBackEventReference-Methode&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://www.aspnetzone.de/aggbug.aspx?PostID=180624" width="1" height="1"&gt;</description><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Artikel/default.aspx">Artikel</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control/default.aspx">Control</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/CustomControl/default.aspx">CustomControl</category><category domain="http://www.aspnetzone.de/blogs/peterbucher/archive/tags/Control%20Entwicklung/default.aspx">Control Entwicklung</category></item></channel></rss>