Kita bisa menambahkan pane secara dinamis melalui CodeBehind. berikut adalah kode nya.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="View.aspx.cs" Inherits="AspCs.faq.View" %>
<%@ Register
Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="ajax" %>
SelectedIndex="0"
HeaderCssClass="AccordionHeader"
HeaderSelectedCssClass="AccordionHeaderSelected"
ContentCssClass="AccordionContent"
AutoSize="None"
FadeTransitions="true"
TransitionDuration="250"
FramesPerSecond="40"
RequireOpenedPane="true"
SuppressHeaderPostbacks="true">
Kode Pada CodeBehind
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DataAccessFacade.TMIFaqDao;
using BusinessObject.TMIFaq;
namespace AspCs.faq
{
public partial class View : System.Web.UI.Page
{
QuestionDao qDao = new QuestionDao();
protected void Page_Load(object sender, EventArgs e)
{
List lq = qDao.Select("categoryId", "1");
foreach (Question q in lq)
{
Label lblTitle = new Label();
Label lblContent = new Label();
lblTitle.Text = q.Questions;
lblContent.Text = q.Answer;
AjaxControlToolkit.AccordionPane pane = new AjaxControlToolkit.AccordionPane();
pane.ID = "pane1" + q.Id;
pane.HeaderContainer.Controls.Add(lblTitle);
pane.ContentContainer.Controls.Add(lblContent);
accordionFAQ.Panes.Add(pane);
}
}
}
}
0 komentar:
Posting Komentar