gpt4 book ai didi

c# - 如何在 AJAX 选项卡容器中获取 ASP.NET 复选框列表对象

转载 作者:行者123 更新时间:2023-11-30 17:14:41 25 4
gpt4 key购买 nike

我在 AJAX 选项卡容器中插入了一个 ASP.NET 复选框列表控件。现在我需要创建该控件的对象以访问我的 C# 代码隐藏文件中的复选框列表。

这是我在其中创建复选框列表的 HTML:

<ajaxToolkit:TabContainer ID="tcPrescription" runat="server" Height="444px">
<ajaxToolkit:TabPanel runat="server" ID="indoor" Height="430px">
<HeaderTemplate>
Indoor Prescription
</HeaderTemplate>
<ContentTemplate>
<div id="bottomcontainer" style="height:420px;">
<div id="bottomleft" style="float:left;height:420px;width:400px;text-align:center;">
<asp:Panel ID="pnlMedicines" runat="server" HorizontalAlign="Center"
ScrollBars="Vertical" Height="375px" Width="389px">
<center>
<asp:CheckBoxList ID="cblMedicines" runat="server" BackColor="White"
BorderColor="#669900" BorderStyle="Solid" BorderWidth="1px"
Height="350px" Font-Bold="False" ForeColor="Black" Width="316px"
DataSourceID="dsMedicines" DataTextField="MedicineName"
DataValueField="MedicineName" >
</asp:CheckBoxList>
...
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>

这是我在代码隐藏文件中的代码:

CheckBoxList cblMedicines = (CheckBoxList)tcPrescription.FindControl("cblMedicines");

它为 cblMedicines 返回一个 null 对象。那么如何访问 AJAX 选项卡容器内的复选框列表控件呢?

请帮我解决这个问题。

最佳答案

你可以尝试使用

CheckBoxList cblMedicines = (CheckBoxList)pnlMedicines.FindControl("cblMedicines");

相反。

cblMedicines 驻留在 pnlMedicines 控件中;在后者的 child 下找更常见。

祝你好运!

关于c# - 如何在 AJAX 选项卡容器中获取 ASP.NET 复选框列表对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8550435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com