Control class has no text property in webcontrols?

Discussion in 'ASP .Net' started by =?Utf-8?B?VGltX2s=?=, Mar 14, 2006.

  1. 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=?=, Mar 14, 2006
    #1
    1. Advertisements

  2. Why not just cast the variable( ((Label)ctrl).Text = ... ).

    "Tim_k" <> wrote in message
    news:...
    > 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, Mar 14, 2006
    #2
    1. Advertisements

  3. "Peter Rilling" wrote:

    > Why not just cast the variable( ((Label)ctrl).Text = ... ).
    >
    > "Tim_k" <> wrote in message
    > news:...
    > > 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=?=, Mar 14, 2006
    #3
  4. 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" <> wrote in message
    > news:...
    > > 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=?=, Mar 14, 2006
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob of the West
    Replies:
    1
    Views:
    3,212
    William F. Robertson, Jr.
    May 17, 2004
  2. Kay
    Replies:
    0
    Views:
    541
  3. E11
    Replies:
    1
    Views:
    5,793
    Thomas Weidenfeller
    Oct 12, 2005
  4. TS
    Replies:
    3
    Views:
    503
    =?Utf-8?B?VFM=?=
    Oct 6, 2006
  5. Nathan Sokalski
    Replies:
    25
    Views:
    1,859
    Nathan Sokalski
    Mar 4, 2010
  6. Samuel

    Update Property that mapped to a child control's property ?

    Samuel, Jan 23, 2006, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    330
    Steven Cheng[MSFT]
    Jan 24, 2006
  7. Mirek Endys
    Replies:
    5
    Views:
    328
    Steven Cheng[MSFT]
    Nov 17, 2005
  8. Spam Catcher
    Replies:
    4
    Views:
    278
    Darko
    Nov 21, 2007
Loading...