setting the Text Property of WebControl if possible

M

Matze

I have a function that has an Argument of type
System.Web.UI.WebControls.WebControl. I want to set the text-property
of that control. Of course it doesnt work if I cast that control to
(WebControl), because WebControl doesnt have a property Text.
Most Controls that inherit WebControl have text so I guess there must
be an common Interface implemented, but cant figure out what it is.
Goal would be something like:

private function translateCntrl(WebControl cntrl){
(ImaginaryControlTextType)cntrl.Text = translateString( cntrl.Text);
}

at the momemt i have tons of functions like

private function translateCntrl(Label cntrl){
(Label)cntrl.Text = translateString( cntrl.Text);
}
private function translateCntrl(Button cntrl){
(Button)cntrl.Text = translateString( cntrl.Text);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top