Control class has no text property in webcontrols?

G

Guest

Does anyone know how to set the text property for a control that is loaded
into the Control class in a web form? The text property exists for Windows
forms but not for web pages? I'd like to set the control.text property as
below.
Thanks,
Tim

foreach (Control ctrl in
MultiView1.Views[MultiView1.ActiveViewIndex].Controls)
{

if (ctrl is Label) {
if (gvRow.Cells[4].Text != null) {
//the line below errors since there is no text
property for ctrl
ctrl.Text = gvRow.Cells[4].Text;
ctrl.Visible = true;
}
else
ctrl.Visible = false;
}
 
G

Guest

Peter Rilling said:
Why not just cast the variable( ((Label)ctrl).Text = ... ).

Tim_k said:
Does anyone know how to set the text property for a control that is loaded
into the Control class in a web form? The text property exists for
Windows
forms but not for web pages? I'd like to set the control.text property as
below.
Thanks,
Tim

foreach (Control ctrl in
MultiView1.Views[MultiView1.ActiveViewIndex].Controls)
{

if (ctrl is Label) {
if (gvRow.Cells[4].Text != null) {
//the line below errors since there is no text
property for ctrl
ctrl.Text = gvRow.Cells[4].Text;
ctrl.Visible = true;
}
else
ctrl.Visible = false;
}
 
G

Guest

That worked! I forgot to mention I'm new to C#.
Thanks Peter

Peter Rilling said:
Why not just cast the variable( ((Label)ctrl).Text = ... ).

Tim_k said:
Does anyone know how to set the text property for a control that is loaded
into the Control class in a web form? The text property exists for
Windows
forms but not for web pages? I'd like to set the control.text property as
below.
Thanks,
Tim

foreach (Control ctrl in
MultiView1.Views[MultiView1.ActiveViewIndex].Controls)
{

if (ctrl is Label) {
if (gvRow.Cells[4].Text != null) {
//the line below errors since there is no text
property for ctrl
ctrl.Text = gvRow.Cells[4].Text;
ctrl.Visible = true;
}
else
ctrl.Visible = false;
}
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top