![]() |
Control class has no text property in webcontrols?
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; } |
Re: Control class has no text property in webcontrols?
Why not just cast the variable( ((Label)ctrl).Text = ... ).
"Tim_k" <Timk@discussions.microsoft.com> wrote in message news:49A5EB35-705C-4BE6-8B17-BE682D6A5F57@microsoft.com... > 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; > } > |
Re: Control class has no text property in webcontrols?
"Peter Rilling" wrote: > Why not just cast the variable( ((Label)ctrl).Text = ... ). > > "Tim_k" <Timk@discussions.microsoft.com> wrote in message > news:49A5EB35-705C-4BE6-8B17-BE682D6A5F57@microsoft.com... > > 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; > > } > > > > > |
Re: Control class has no text property in webcontrols?
That worked! I forgot to mention I'm new to C#.
Thanks Peter "Peter Rilling" wrote: > Why not just cast the variable( ((Label)ctrl).Text = ... ). > > "Tim_k" <Timk@discussions.microsoft.com> wrote in message > news:49A5EB35-705C-4BE6-8B17-BE682D6A5F57@microsoft.com... > > 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; > > } > > > > > |
| All times are GMT. The time now is 01:23 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.