Professional Web Applications Themes

Looking for user collapsable panels - ASP Components

I'm looking for a 3rd party component that is a regular container and which the user can open or collapse. Each needs to be able to contain buttons and labels....

  1. #1

    Default Looking for user collapsable panels

    I'm looking for a 3rd party component that is a regular container and which
    the user can open or collapse. Each needs to be able to contain buttons and
    labels.
    ChrisA Guest

  2. #2

    Default RE: Looking for user collapsable panels

    "ChrisA" wrote:
    > I'm looking for a 3rd party component that is a regular container and which
    > the user can open or collapse. Each needs to be able to contain buttons and
    > labels.
    Chris,

    For our project we had a similar requirement. We solved this by extending
    the panel class somewhat. I realise taht this may not be what you are looking
    for. Feel free to disregard this post if it's not helpfull.

    Kind regards,

    Martijn

    The code is not too big and fairly straightforward, so I'll add it below:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI.WebControls;
    using System.Web.UI;
    using System.ComponentModel;

    namespace MyWebControls
    {
    public class MyPanel : System.Web.UI.WebControls.Panel
    {
    private ImageButton iButton = new ImageButton();
    private Label iLabel = new Label();

    public CCPanel()
    {
    iButton.Click += new ImageClickEventHandler(iButton_Click);
    this.Controls.Add(iButton);
    }

    [Bindable(true),
    Category("Appearance"),
    DefaultValue("")]
    public string label
    {
    get
    {
    return iLabel.Text;
    }
    set
    {
    iLabel.Text = value;
    }
    }

    [Bindable(true),
    Category("Appearance"),
    DefaultValue("true")]
    public Boolean open
    {
    get
    {
    Object lObject = ViewState["isOpen"];
    if (lObject != null) return (Boolean)lObject;
    return true;
    }
    set
    {
    ViewState["isOpen"] = value;
    }
    }

    protected override void OnInit(EventArgs pE)
    {
    iButton.ImageUrl = "~/_images/minus_wh.gif";
    if (Width.IsEmpty) Width = new Unit("100%");
    base.OnInit(pE);
    }

    protected override void Render(System.Web.UI.HtmlTextWriter pWriter)
    {
    pWriter.Write("<table class=\"tb_ccpanel\" width=\"" +
    Width.ToString() + "\" cellspacing=\"0\">\n");
    if (open)
    pWriter.Write("<tr class=\"tr_ccpanel_open
    tr_ccpanel_header\" style=\"" + Width.ToString() + ";\"><td
    class=\"td_ccpanel_header\">\n");
    else
    pWriter.Write("<tr class=\"tr_ccpanel_closed
    tr_ccpanel_header\" style=\"" + Width.ToString() + ";\"><td
    class=\"td_ccpanel_header\">\n");
    iButton.RenderControl(pWriter);
    pWriter.Write(" ");
    iLabel.RenderControl(pWriter);
    pWriter.Write("</td></tr>");
    iButton.Visible = false;
    if (open)
    pWriter.Write("<tr><td class=\"td_ccpanel_content\">\n");
    Visible = open;
    RenderBeginTag(pWriter);
    if (open) RenderContents(pWriter);
    RenderEndTag(pWriter);
    if (open)
    pWriter.Write("</td></tr>");
    pWriter.Write("</table>");
    }


    private void SetModeReadonly(Control pControl)
    {
    if (pControl.HasControls())
    foreach (Control lControl in pControl.Controls)
    SetModeReadonly(lControl);
    if (pControl is DetailsView)
    ((DetailsView)pControl).ChangeMode(DetailsViewMode .ReadOnly);
    if (pControl is GridView)
    ((GridView)pControl).EditIndex = -1;
    }

    private void iButton_Click(Object pSender, EventArgs pArgs)
    {
    if (open)
    {
    open = false;
    iButton.ImageUrl = "~/_images/plus_wh.gif";
    SetModeReadonly(this);
    }
    else
    {
    open = true;
    iButton.ImageUrl = "~/_images/minus_wh.gif";
    }
    }
    }
    }

    Mind that you set the image locations, "~/_images/minus_wh.gif" and
    "~/_images/plus_wh.gif" to the locations of your own images. Also, since we
    have only assigned CSS classes to the HTML table and it's elements, proper
    layout will require some additional entries in your stylesheet.
    Martijn Guest

  3. #3

    Default RE: Looking for user collapsable panels

    Martijn,
    Thanks very much for your post. I like your implementation.
    -- Chris
    ChrisA Guest

Similar Threads

  1. Collapsable functions and classes like in Visual Studio andKomodo 3.1
    By danilocelic *TMM* in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 0
    Last Post: April 4th, 05:25 PM
  2. Collapsable functions and classes like in Visual Studioand Komodo 3.1
    By wyrmhaven in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: April 4th, 05:18 PM
  3. viewstate for collapsable panel control
    By Cappy in forum ASP.NET Building Controls
    Replies: 3
    Last Post: June 24th, 07:10 PM
  4. Collapsable Menu Problem
    By Lobosx34 webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: February 3rd, 07:48 PM
  5. Help Me With A Flash Collapsable Menu
    By S. Guthrie webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 0
    Last Post: November 10th, 09:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139