このような気がするのは簡単ですが、一日を見回した後、私はいくつかの助けを求めています! Web Formsアプリケーションがあり、AJAX Control Toolkit(v16.1)からアコーディオンを作成しました。私のコードの背後には、入力フォルダからファイルのリストを取得し、それらを繰り返します。ロジックを並べ替えることができますが、これらのファイルのそれぞれには、あらかじめ定義された6つのアコーディオンペインヘッダーの間に適切な場所があります。コンテンツは、ソートロジックを満たすために必要な数のクリック可能なボタンを格納するためのものです。いずれかのボタンがクリックされると、My DBコンテキストのget()メソッドが呼び出され、近くのパネルにGridViewが設定されます。あなたは、例としてMicrosoft Outlookを考えることができます。電子メールは、日付順にソートされ、個々にクリック可能で、近くのビューでレンダリングされます。AJAX Toolkitアコーディオンの中にどのようにボタンを動的に追加できますか?
私の問題は、ファイルが現在アコーディオンペインのコンテンツ領域にLiteralControlとして入力されていることです。代わりにボタンを追加しようとしていますが、私は他の提案にもオープンしています。私はちょうどクリック能力が必要なので、GridViewを適切に配置することができます。ここにあなたの助けを事前に感謝、とは熟考するために私のコードの一部である...
Default.aspxの
...
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<asp:GridView ID="TransactionGridView" runat="server" DataSourceID="TransactionODS" CellPadding="4" ForeColor="#333333" GridLines="None" >
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#5078B3" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5078B3" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#D3DEEF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<asp:ObjectDataSource ID="TransactionODS" runat="server" SelectMethod="GetTransactionSet" TypeName="ZipApprove.Models.TransactionRepository"></asp:ObjectDataSource>
</asp:Content>
<asp:Content ID="HistoryNavigationContent" ContentPlaceHolderID="NavigationPanel" runat="server">
<ajaxToolkit:Accordion
ID="HistoryAccordion"
runat="server"
SelectedIndex="0"
HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent"
AutoSize="None"
Height="450"
FadeTransitions="true"
TransitionDuration="250"
FramesPerSecond="40"
RequireOpenedPane="false"
SuppressHeaderPostbacks="true">
<Panes></Panes>
<HeaderTemplate></HeaderTemplate>
<ContentTemplate></ContentTemplate>
</ajaxToolkit:Accordion>
</asp:Content>
Default.aspx.cs
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
var files =
Directory.GetFiles(
Server.MapPath("Output_Files"),
"*.*",
SearchOption.AllDirectories
);
// Create the date panes and give them a header
...
AccordionPane lastWeek = new AccordionPane();
lastWeek.HeaderContainer.Controls
.Add(new LiteralControl("A Week Ago"));
...
foreach (var file in files)
{
var fileInfo = new FileInfo(file);
if (fileInfo.Extension == ".csv")
{
string fileDTString =
fileInfo.Name.Substring(
fileInfo.Name.Length - 16,
12
);
DateTime dateTime =
DateTime.ParseExact(
fileDTString,
"MMddyyyyHHmm",
CultureInfo.InvariantCulture
);
...
else if (
dateTime >=
DateTime.Now
.AddDays(-7)
.AddHours(-DateTime.Now.Hour)
.AddMinutes(-DateTime.Now.Minute) &&
dateTime <
DateTime.Now
.AddDays(-1)
.AddHours(-DateTime.Now.Hour)
.AddMinutes(-DateTime.Now.Minute)
)
{
// Parsed between 1 week ago at midnight and up to, not
// including, midnight of the case above
lastWeek.ContentContainer.Controls.Add(
new LiteralControl(
fileInfo.Name.Substring(
0, fileInfo.Name.Length - 4
)
)
);
lastWeek.ContentContainer.Controls.Add(
new Literal()
{
Mode = LiteralMode.PassThrough,
Text = "<br/><br/>"
}
);
}
else if (
...
} // End of CSV "If"
} // End of looping through files
...
HistoryAccordion.Panes.Add(lastWeek);
...
} // End of Page Load method
} // End of class
} // End of namespace
サイト。マスター*
...
<div id="panelsDiv" style="display:flex">
<div
ID="NavigationPanelContainer"
style="
margin: 5px 5px 5px 5px;
width: 250px;
overflow-y: auto;
color: black;
height: 500px">
<asp:ContentPlaceHolder ID="NavigationPanel" runat="server"></asp:ContentPlaceHolder>
</div>
<div class="container body-content"
ID="ContentPanelContainer"
style="
flex: 1;
height: 500px;
margin: 5px 5px 5px 5px;
overflow-y: auto;">
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
</div>
...
これら2つのファイル名がクリック可能である必要があり、パネルの1
を示す
例ラン。何か案は?
リテラルの代わりにパネルを使用してボタンやリンクを追加してみませんか?また、ここでは、ハイパーリンクやボタンではなく、リテラルとしてファイル名を追加していますか?新しいLiteralControl(fileInfo.Name.Substring(0、fileInfo.Name.Length - 4) – Krishna
@Krishna、ありがとうございました。私が提案したようにパネルを使用し、そのトリックを行いました。正しい?ありがとう! –