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
___
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
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
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.
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