我試圖通過Page.Controls
獲取我的頁面中的所有控件,但它僅返回他的Master Page
控件,如何才能獲得此內容頁面控件?如何使用C#獲取內容頁面中的所有控件?
<%@ Page Title="" Language="C#" MasterPageFile="~/Template/ManagerTemplate.Master" AutoEventWireup="true" CodeBehind="Cliente.aspx.cs" Inherits="SistemaPedido.Cadastro.Cliente" %>
我的事件
protected void Page_Load(object sender, EventArgs e)
{
Page.LoadComplete += (s, arg) =>
{
foreach (Control Control in Page.Controls)
{
Response.Write(Control.ClientID + "<br/>");
}
};
}
非常感謝你! – Lai32290
你不能從靜態方法中訪問非靜態lst_controls。 –