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 14 September 2006 10:47 PM by Ken Cox [MVP]
Filed under:

Comments

# WebLog of Ken Cox : Creating a GroupBox in ASP.NET said on 14 September, 2006 11:06 PM

PingBack from http://weblogs.asp.net/kencox/archive/2006/09/14/Creating-a-GroupBox-in-ASP.NET.aspx

# Murali said on 20 July, 2007 07:35 AM

this is very helpfull

# DotNetKicks.com said on 30 July, 2007 02:41 PM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# LeHieu said on 09 November, 2007 02:29 AM

thank you so much!!

# Durgadevi.S said on 30 January, 2008 01:31 AM

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

# sudip said on 31 January, 2008 05:48 AM

thankzz for the code..it helpd me lot.

# chiranjeevi said on 02 February, 2008 07:37 AM

this has helped me a lot in doing my work

thank for providing this

# SHIVAPRAKASH said on 31 March, 2008 05:56 AM

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

# Anand said on 05 May, 2008 01:21 AM

How to change the color of the grouping text?

Thanks in Advance

-Anand

# kamal said on 15 May, 2008 03:12 PM

thanks , its helpfull

# Sculptor said on 06 March, 2009 07:20 PM

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

# Hemendra said on 21 April, 2009 07:59 AM

Thanks

Leave a Comment

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

Search

Go

This Blog

Web Links

Syndication