Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Control class has no text property in webcontrols? (http://www.velocityreviews.com/forums/t121510-control-class-has-no-text-property-in-webcontrols.html)

=?Utf-8?B?VGltX2s=?= 03-14-2006 01:47 AM

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;
}


Peter Rilling 03-14-2006 03:37 AM

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;
> }
>




=?Utf-8?B?VGltX2s=?= 03-14-2006 02:30 PM

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;
> > }
> >

>
>
>


=?Utf-8?B?VGltX2s=?= 03-14-2006 02:32 PM

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.