我正在研究asp.net web應用程序。我使用佔位符和用戶控件在一個頁面中動態創建控件。裏面的佔位符有多個文本框。如何獲取Asp.Net Web應用程序中PlaceHolder中控件的服務器端Id?
我在for循環中運行此代碼。
phSchemaEMITenureDetails.Controls.Add(LoadControl("~/UserControl/SchemaEMITenureDetails.ascx"));
意思是,我想創建多組這些文本框。
所有工作正常,但現在我想要獲取用戶在服務器端的這些文本框中輸入的文本數據。所以我需要在服務器端的這些控件的Id。
我無法得到。請幫我出
用戶控制:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SchemaEMITenureDetails.ascx.cs" Inherits="PaymentControllerGUI.SchemaEMITenureDetails" %>
<asp:Label runat="server" ID="SchemaRowName"></asp:Label>
<asp:Table runat="server">
<asp:TableRow runat="server" ID="SchemaEMITenure03MonthRow" Style="display: none;">
<asp:TableCell>
<asp:Label runat="server" Text="EMI 03 Months" ID="SchemaEMITenure03MonthLabel">
</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox runat="server" ID="SchemaEMITenure03MonthTextBox">
</asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server" ID="SchemaEMITenure06MonthRow" Style="display: none;">
<asp:TableCell>
<asp:Label runat="server" Text="EMI 06 Months" ID="SchemaEMITenure06MonthLabel">
</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="SchemaEMITenure06MonthTextBox" runat="server">
</asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server" ID="SchemaEMITenure09MonthRow" Style="display: none;">
<asp:TableCell>
<asp:Label runat="server" Text="EMI 09 Months" ID="SchemaEMITenure09MonthLabel">
</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="SchemaEMITenure09MonthTextBox" runat="server">
</asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server" ID="SchemaEMITenure12MonthRow" Style="display: none;">
<asp:TableCell>
<asp:Label runat="server" Text="EMI 12 Months" ID="SchemaEMITenure12MonthLabel">
</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="SchemaEMITenure12MonthTextBox" runat="server">
</asp:TextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
頁.aspx的:
<asp:PlaceHolder ID="phSchemaEMITenureDetails" runat="server"></asp:PlaceHolder>
頁Aspx.cs:phSchemaEMITenureDetails.Controls.Add(LoadControl("~/UserControl/SchemaEMITenureDetails.ascx"));