Re: AW: [Asp.net] Problem mit dynamischem Casten

2004-12-26 Diskussionsfäden Christoph Schmid
versuch mal das: if (control.GetType() == typeof(TextBox)) { ((TextBox)control).Text = "test 1"; } else if (control.GetType() == typeof(Label)) { ((Label)control).Text = "test 2"; } Ja, das geht so schon. Ist nur nicht so schön. Ist aber wohl das einzig mögliche. Gruss Christoph ___

Re: [Asp.net] Problem mit dynamischem Casten

2004-12-26 Diskussionsfäden Christoph Schmid
MyFunction(., System.Type DataType) if(DataType == typeof(int)) { // bla bla } Werde ich wohl auch machen müssen. Aufruf: MyFunction(., typeof(int)) Evtl. sollte Dein Code (C#) auch so funktionieren: ((control.GetType())control).Text = "hello world!"; Nein, geht leider ned. Wies s

AW: [Asp.net] Problem mit dynamischem Casten

2004-12-26 Diskussionsfäden Kristian Tingler
Hi, versuch mal das: if (control.GetType() == typeof(TextBox)) { ((TextBox)control).Text = "test 1"; } else if (control.GetType() == typeof(Label)) { ((Label)control).Text = "test 2"; } Das Beispiel habe ich in C# g

RE: [Asp.net] Problem mit dynamischem Casten

2004-12-26 Diskussionsfäden Alexander Zeitler
Hallo, > > Ich übergeben einer Funktion ein WebControl und prüfe dann, dass das > WebControl z.B. von TextBox, Label,... (Controls mit > Text-Attribut) ist. > Wenn dem der Fall ist, möchte ich das .Text zuweisen. > Müsste dazu einen Cast machen wobei ich erst zur Laufzeit > weis, welcher Typ.

[Asp.net] Problem mit dynamischem Casten

2004-12-26 Diskussionsfäden Christoph Schmid
Hallo Ich übergeben einer Funktion ein WebControl und prüfe dann, dass das WebControl z.B. von TextBox, Label,... (Controls mit Text-Attribut) ist. Wenn dem der Fall ist, möchte ich das .Text zuweisen. Müsste dazu einen Cast machen wobei ich erst zur Laufzeit weis, welcher Typ. Sowas wie: (contro