Creating a GroupBox in ASP.NET

Someone asked the other day in the newsgroups about creating a Windows-style groupbox in ASP.NET. I knew I had seen one used somewhere in a Web page, and finally tracked it down. It turns out to be the <fieldset> tag with an embedded <legend> to hold the text.

In ASP.NET, use the Panel control and provide a text value to the groupingtext attribute.

Here's some ASP.NET code:

<asp:panel id="Panel1" runat="server" groupingtext="Using the Fieldset Element">
    <table width="100%">
        <tr>
            <td>
                <asp:radiobutton id="radGrp1" runat="server" groupname="rads" />
            </td>
            <td>
                <asp:label id="lblLegend" runat="server" text="Use the Legend Tag!" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:radiobutton id="radGrp2" checked="true" groupname="rads" runat="server" /></td>
            <td>
                <asp:label id="lblGroup" runat="server" text="Creates a Groupbox in HTML!">
                </asp:label>
            </td>
        </tr>
    </table>
</asp:panel>

Here's the HTML spec's reference for the tag:

 http://www.w3.org/TR/html4/interact/forms.html#edef-FIELDSET

Published Thursday, September 14, 2006 10:47 PM by Ken Cox [MVP]
Filed under:

Comments

# re: Creating a GroupBox in ASP.NET

Friday, July 20, 2007 7:35 AM by Murali

this is very helpfull

# re: Creating a GroupBox in ASP.NET

Friday, November 9, 2007 2:29 AM by LeHieu

thank you so much!!

# re: Creating a GroupBox in ASP.NET

Wednesday, January 30, 2008 1:31 AM by Durgadevi.S

Thanku so much i was ineed of the same for more than a day. Thanku it was very useful

# re: Creating a GroupBox in ASP.NET

Thursday, January 31, 2008 5:48 AM by sudip

thankzz for the code..it helpd me lot.

# re: Creating a GroupBox in ASP.NET

Saturday, February 2, 2008 7:37 AM by chiranjeevi

this has helped me a lot in doing my work

thank for providing this

# re: Creating a GroupBox in ASP.NET

Monday, March 31, 2008 5:56 AM by SHIVAPRAKASH

THANKS A LOT.. I WILL CHECK THIS IF ITS WORKING I WILL CONVEY YOU

# re: Creating a GroupBox in ASP.NET

Monday, May 5, 2008 1:21 AM by Anand

How to change the color of the grouping text?

Thanks in Advance

-Anand

# re: Creating a GroupBox in ASP.NET

Thursday, May 15, 2008 3:12 PM by kamal

thanks , its helpfull

# re: Creating a GroupBox in ASP.NET

Friday, March 6, 2009 7:20 PM by Sculptor

Was very helpful. Thanks a lot. U r the man...

# re: Creating a GroupBox in ASP.NET

Wednesday, September 16, 2009 1:05 AM by Hemnath

tht was a perfect one

# re: Creating a GroupBox in ASP.NET

Thursday, April 14, 2011 1:59 PM by Arpit

Very Nice...

looking For this...

ty a lot..

# re: Creating a GroupBox in ASP.NET

Saturday, June 4, 2011 12:44 AM by Lakshmi narasimha

It is very helpful. Thanks a lot.

Leave a Comment

(required) 
(required) 
(optional)
(required)