0
我有一個面板,我試圖從後面的代碼添加一個用戶控件。問題是一旦代碼運行,加載的控件不會出現在面板中。我錯過了什麼嗎?動態添加用戶控件到頁面
<div id="ShippingDetails" runat="server" visible="true">
<asp:Panel ID="Panel1" runat="server"></asp:Panel>
</div>
</form>
</asp:Content>
後面的代碼:
protected void Page_PreRender(object sender, EventArgs e)
{
if (OrderSearch1.SelectedValues != null)
{
InitializeShippingDetailControls();
}
}
public void InitializeShippingDetailControls()
{
admin_InputControl control = new admin_InputControl();
control.InitializeInputControl(ShippingDetailInputControls, new DataModels.EDIOrderShipmentInfo(), 1, "Shipment Details");
Panel1.Controls.Add(control);
}