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. Advertising

  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. Advertising

  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. Advertising

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. gane kol
    Replies:
    1
    Views:
    355
    Scott Allen
    Apr 15, 2005
  2. E11
    Replies:
    1
    Views:
    4,850
    Thomas Weidenfeller
    Oct 12, 2005
  3. tanya foster
    Replies:
    3
    Views:
    3,763
    tanya foster
    May 18, 2006
  4. Mutley

    Property Window and 3rd party webcontrols

    Mutley, Mar 14, 2007, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    105
    Mutley
    Mar 14, 2007
  5. lavey
    Replies:
    3
    Views:
    289
Loading...

Share This Page