Hallo,

wenn ein Postback durchgef�hrt wurde kann dein geladenes Control nicht mehr
existieren, da dein DropDownList1_SelectedIndexChanged nicht mehr ausgef�hrt wird.

Du kann es vieleicht so umgehen, dass Du Tools.LoadControl im PageLoad aufrufs

if(ViewState["__loadedControl"] != null)
        Tools.Tools.LoadControl(this, AdBody,ViewState["loadedControl"] + ".ascx");


In der Methode DropDownList1_SelectedIndexChanged
{
        Tools.LoadControl(this, AdBody, DropDownList1.SelectedItem.Text.Trim() + 
".ascx");
        ViewState["__loadedControl"] =  DropDownList1.SelectedItem.Text.Trim();
}

Hoffe der Ansatz kann Dir weiterhelfen

J�rg

-----Urspr�ngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Auftrag von Michael Guder
Gesendet: Samstag, 26. Juni 2004 17:15
An: [EMAIL PROTECTED]
Betreff: [Asp.net] UserControls dynamisch laden..


Hi Liste,

ich hab hier ein Problemchen: Ich m�chte abh�ngig von einer
Dropdownauswahl ein UC dynamisch laden.

Leider vergisst meine Seite jetzt aber bei irgendeinem PostBack die
geladenen Controls ^^ kann man so was nicht irgendwie umgehen?

St�ckchen Source:

private void DropDownList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
        Tools.LoadControl(this, AdBody,
DropDownList1.SelectedItem.Text.Trim() + ".ascx");
}


Class Tools:
                public static void LoadControl(TemplateControl template,

                        Control target, string ControlName)
                {

target.Controls.Add(template.LoadControl(ControlName));
                }


Viele Gr��e,

Micha

*************************
_______________________________________________
This ASP.NET email is sponsored by:
UDEX ProMenu.Net  - Die Software f�r Navigation - Jetzt kostenlos testen!
Tree- Style, Horizontal- Slide, Vertical- Slide. http://www.udexnet.com

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

*************************
_______________________________________________
This ASP.NET email is sponsored by:
UDEX ProMenu.Net  - Die Software f�r Navigation - Jetzt kostenlos testen!
Tree- Style, Horizontal- Slide, Vertical- Slide. http://www.udexnet.com

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

Antwort per Email an