views:

23

answers:

2

Currently I'm working on a extensive form, which I'd like to organise by grouping input fields in groupbox-like panels. These panels have an header, a minimize and pin icon. Also inner controls should be able to perform two-way binding to the FormViews datasource.

I can't find any builtin asp.net control that does the job. What is the best way to accomplish this feature request? Any examples available on this (can't find a decent one)?

Many thanks!

+1  A: 

Templated controls will get the job done. Check out these links for more information:

Gabriel McAdams
Please remember to accept this answer if you found it useful.
Gabriel McAdams
A: 

Tuturials are interesting, but didn't realy need templated controls at the moment, neither databound controls. Only controls in the controlcollection should be able to do so, but apparently they're able by default.

Found out multiple ways to accomplish. One to extend the default Panel control, the other one to extend from WebControl as shown below. Works as intended.

[DefaultProperty("HeaderText")]
[ToolboxData(@"<{0}:FormGroupBox runat=""server"" HeaderText=""Title""></{0}:FormGroupBox>")]
[PersistChildren(true), ParseChildren(false, "Controls")]
public class FormGroupBox : WebControl
{
    [Bindable(true)]
    [Category("Appearance")]
    [DefaultValue("")]
    [Localizable(true)]
    public string HeaderText
    {
        get
        {
            String s = (String) ViewState["HeaderText"];
            return ((s == null) ? "[" + this.ID + "]" : s);
        }

        set
        {
            ViewState["HeaderText"] = value;
        }
    }

    protected override void RenderContents(HtmlTextWriter output)
    {
        output.Write(string.Format("<strong>{0}</strong>", this.HeaderText));
        output.Write(@"<hr />");

        base.RenderContents(output);
    }
}
Monty