[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to add Ajax Collapsible panel (with sliding effect) inside an asp.net datalist control?

Posted on 2009-04-17
4
Medium Priority
?
2,002 Views
Last Modified: 2012-05-06
I'm having a datalist that shows messages and their titles. By using Anthem it works like initially user is having message titles visible and when usre clicks on any title then the anthem panel opens to show the message details.

My requirement is to make this details panel open and collapse with sliding effect, some thing like mootools (http://demos.mootools.net/Fx.Slide) verticle sliding panel works. I'm unable to add that panel into the datalist control.

Please help.
0
Comment
Question by:23-degrees
  • 2
4 Comments
 
LVL 9

Expert Comment

by:tetorvik
ID: 24166390
You can define your datalist ItemTemplate like below:

Hope this helps!
  <asp:DataList runat="server" ID="myDataList">
            <ItemTemplate>
                <table>
                    <tr>
                        <td><asp:LinkButton ID="lnkShowOrHide" runat="server" Text="Title"/></td>
                    </tr>
                </table>
                <asp:Panel ID="myPanel" runat="server" Height="0">
                    <div style="border: solid 1px; background-color: gray;">
                       Your content here!!
                    </div>
                </asp:Panel>
 
                <ajaxToolkit:CollapsiblePanelExtender ID="collapsiblePanel" runat="Server"
                    TargetControlID="myPanel"
                    ExpandControlID="lnkShowOrHide"
                    CollapseControlID="lnkShowOrHide" 
                    Collapsed="True"
                    ExpandedText=""
                    CollapsedText=""
                    CollapsedSize="0"
                    SuppressPostBack="true" />
            </ItemTemplate>
        </asp:DataList>

Open in new window

0
 
LVL 14

Accepted Solution

by:
GiftsonDJohn earned 1000 total points
ID: 24166424
Hi,

Please find the sample code attached
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div>
            <asp:DataList ID="DataList1" runat="server">
                <ItemTemplate>
                    <asp:Panel ID="Panel2" runat="server" CssClass="collapsePanelHeader" Height="30px">
                        <div style="padding: 5px; cursor: pointer; vertical-align: middle;">                            
                            <div style="float: left; margin-left: 20px;">
                                <asp:Label ID="Label1" runat="server"><%#DataBinder.Eval(Container.DataItem, "Title") %></asp:Label>
                            </div>
                            <div style="float: right; vertical-align: middle;">
                                <asp:ImageButton ID="Image1" runat="server" ImageUrl="~/images/expand_blue.jpg" AlternateText="(Show Details...)" />
                            </div>
                        </div>
                    </asp:Panel>
                    <asp:Panel ID="Panel1" runat="server" CssClass="collapsePanel" Height="0">
                        <br />
                        <p>
                           <%#DataBinder.Eval(Container.DataItem,"Description") %>
                        </p>
                    </asp:Panel>
                    <ajaxToolkit:CollapsiblePanelExtender ID="cpeDemo" runat="Server" TargetControlID="Panel1"
                        ExpandControlID="Panel2" CollapseControlID="Panel2" Collapsed="True" TextLabelID="Label1"
                        ImageControlID="Image1" ExpandedText="(Hide Details...)" CollapsedText="(Show Details...)"
                        ExpandedImage="~/images/collapse_blue.jpg" CollapsedImage="~/images/expand_blue.jpg"
                        SuppressPostBack="true"/>
                </ItemTemplate>
            </asp:DataList>
        </div>
 
//Code Behind
 
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Title");
            dt.Columns.Add("Description");
 
            for (int i = 1; i < 10; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = "Title" + i;
                dr[1] = "Testing for Description<br/>The Description Count is " + i;
                dt.Rows.Add(dr);
            }
 
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }
    }

Open in new window

0
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24166446
A Small correction please replace the CollapsiblePanelExtender code with below

<ajaxToolkit:CollapsiblePanelExtender ID="cpeDemo" runat="Server" TargetControlID="Panel1"
                        ExpandControlID="Panel2" CollapseControlID="Panel2" Collapsed="True" TextLabelID="Label1"
                        ImageControlID="Image1"
                        ExpandedImage="~/images/collapse_blue.jpg" CollapsedImage="~/images/expand_blue.jpg"
                        SuppressPostBack="true"/>
0
 

Author Closing Comment

by:23-degrees
ID: 31571391
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question