Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Control class has no text property in webcontrols?

Reply
Thread Tools

Control class has no text property in webcontrols?

 
 
=?Utf-8?B?VGltX2s=?=
Guest
Posts: n/a
 
      03-14-2006
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;
}

 
Reply With Quote
 
 
 
 
Peter Rilling
Guest
Posts: n/a
 
      03-14-2006
Why not just cast the variable( ((Label)ctrl).Text = ... ).

"Tim_k" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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;
> }
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?VGltX2s=?=
Guest
Posts: n/a
 
      03-14-2006


"Peter Rilling" wrote:

> Why not just cast the variable( ((Label)ctrl).Text = ... ).
>
> "Tim_k" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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;
> > }
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?VGltX2s=?=
Guest
Posts: n/a
 
      03-14-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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;
> > }
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the value of a Master page's control's property using a property of the Master page Nathan Sokalski ASP .Net 25 03-04-2010 03:42 AM
OO Javascript - Class.Prototype.Property vs. This.Property Spam Catcher Javascript 4 11-21-2007 05:23 PM
Update Property that mapped to a child control's property ? Samuel ASP .Net Building Controls 3 01-24-2006 06:18 AM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Class 'System.Data.SqlClient.SqlDataAdapter' cannot be indexed because it has no default property. Bob of the West ASP .Net 1 05-17-2004 03:30 PM



Advertisments