Guten Morgen allerseits,
ich bin heute ein bisschen am experimentieren und brauche gleich mal
eure Hilfe. Ich habe 2 Klassen geschrieben.
Eine die hei�t "formular.cs" und ist ein Control welches in einem Array
10 Controls vom Typ "item.cs" speichert. Im Formular ist noch ein
Button. Wenn der Button gedr�ckt wird, erfolgt ein Postback. Sinn der
�bung ist es, den Inhalt der Controls ("items") zu erhalten. Das sollte
ja eigentlich automatisch funktionieren. Aber irgendwie geht das noch
nicht.
Formular.cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace controlstest
{
/// <summary>
/// Summary description for formular.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:formular
runat=server></{0}:formular>")]
public class formular : System.Web.UI.WebControls.WebControl
{
controlstest.item [] items = new controlstest.item[10];
Button btn = new Button();
protected override void OnLoad(EventArgs e) {
for(int i=0; i<items.Length; i++) {
items[i] = new
controlstest.item();
}
btn.Load += new EventHandler(this.btn_Click);
}
protected override void CreateChildControls() {
foreach(controlstest.item a in items) {
this.Controls.Add(a);
}
this.Controls.Add(btn);
}
protected void btn_Click(Object sender, EventArgs e) {
this.Controls.Add(new LiteralControl("Button"));
}
}
}
item.cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace controlstest
{
/// <summary>
/// Summary description for item.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:item runat=server></{0}:item>")]
public class item : System.Web.UI.WebControls.WebControl
{
protected TextBox myBox = new TextBox();
protected override void CreateChildControls() {
this.Controls.Add(myBox);
}
}
}
_______________________________________________
Asp.net mailing list
[EMAIL PROTECTED]
http://www.glengamoi.com/mailman/listinfo/asp.net