Generating <label> tag...

Discussion in 'ASP .Net Web Controls' started by scsharma, Jan 6, 2005.

  1. scsharma

    scsharma Guest

    Hi,
    I am using data grid and i want to have a checkbox as one of the column.
    For that i am creating a template class and in InstantiateIn(Control
    container) function i am dynamically creating a check box and adding that
    check box to control collection.
    Since the checkbox generates <input> tag I would like to have corresponding
    label so that i can set the associatedControlID property of the label to
    checkbox. But when final HTML is generated instead of <label> tag I am seeing
    <span> tag.
    What am i doing wrong?Please help.

    Here is the code:

    public void InstantiateIn(Control container)
    {
    CheckBox cbx = new CheckBox();
    Label lbl = new Label();
    cbx.DataBinding +=new EventHandler(cbx_DataBinding);
    lbl.DataBinding+=new EventHandler(lbl_DataBinding);
    if (staticText !="")
    lbl.AssociatedControlID = cbx.ID;
    container.Controls.Add(lbl);
    container.Controls.Add(cbx);
    }




    --
    Thanks
    SCSharma
    scsharma, Jan 6, 2005
    #1
    1. Advertising

  2. what do you mean by this :
    Since the checkbox generates <input> tag I would like to have corresponding
    label so that i can set the associatedControlID property of the label to
    checkbox.
    Are u trying to trach whick checkbox is clicked?
    R. Thomas

    "scsharma" wrote:

    > Hi,
    > I am using data grid and i want to have a checkbox as one of the column.
    > For that i am creating a template class and in InstantiateIn(Control
    > container) function i am dynamically creating a check box and adding that
    > check box to control collection.
    > Since the checkbox generates <input> tag I would like to have corresponding
    > label so that i can set the associatedControlID property of the label to
    > checkbox. But when final HTML is generated instead of <label> tag I am seeing
    > <span> tag.
    > What am i doing wrong?Please help.
    >
    > Here is the code:
    >
    > public void InstantiateIn(Control container)
    > {
    > CheckBox cbx = new CheckBox();
    > Label lbl = new Label();
    > cbx.DataBinding +=new EventHandler(cbx_DataBinding);
    > lbl.DataBinding+=new EventHandler(lbl_DataBinding);
    > if (staticText !="")
    > lbl.AssociatedControlID = cbx.ID;
    > container.Controls.Add(lbl);
    > container.Controls.Add(cbx);
    > }
    >
    >
    >
    >
    > --
    > Thanks
    > SCSharma
    R. Thomas, aka Xtreme.Net, Jan 7, 2005
    #2
    1. Advertising

  3. scsharma

    scsharma Guest

    We have 508 compliance issues where every <input> tag should have associated
    label. The label have to speicfy the control that it is associated to, in
    this case the checkbox. This is done by setting the associatedControlID
    property of label.
    Thanks
    Subhash

    "R. Thomas, aka Xtreme.Net" wrote:

    > what do you mean by this :
    > Since the checkbox generates <input> tag I would like to have corresponding
    > label so that i can set the associatedControlID property of the label to
    > checkbox.
    > Are u trying to trach whick checkbox is clicked?
    > R. Thomas
    >
    > "scsharma" wrote:
    >
    > > Hi,
    > > I am using data grid and i want to have a checkbox as one of the column.
    > > For that i am creating a template class and in InstantiateIn(Control
    > > container) function i am dynamically creating a check box and adding that
    > > check box to control collection.
    > > Since the checkbox generates <input> tag I would like to have corresponding
    > > label so that i can set the associatedControlID property of the label to
    > > checkbox. But when final HTML is generated instead of <label> tag I am seeing
    > > <span> tag.
    > > What am i doing wrong?Please help.
    > >
    > > Here is the code:
    > >
    > > public void InstantiateIn(Control container)
    > > {
    > > CheckBox cbx = new CheckBox();
    > > Label lbl = new Label();
    > > cbx.DataBinding +=new EventHandler(cbx_DataBinding);
    > > lbl.DataBinding+=new EventHandler(lbl_DataBinding);
    > > if (staticText !="")
    > > lbl.AssociatedControlID = cbx.ID;
    > > container.Controls.Add(lbl);
    > > container.Controls.Add(cbx);
    > > }
    > >
    > >
    > >
    > >
    > > --
    > > Thanks
    > > SCSharma
    scsharma, Jan 7, 2005
    #3
    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. Shapper
    Replies:
    2
    Views:
    712
    Scott Mitchell [MVP]
    May 7, 2005
  2. Josef K.

    <label><div></div></label> allowed?

    Josef K., May 20, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    13,262
    Josef K.
    May 22, 2005
  3. shruds
    Replies:
    1
    Views:
    709
    John C. Bollinger
    Jan 27, 2006
  4. Praveen
    Replies:
    1
    Views:
    926
    Rob Williscroft
    Nov 5, 2006
  5. Knut Krueger
    Replies:
    8
    Views:
    238
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page