Question:You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
Your application has a user control named UserCtrl.ascx. You write the following code fragment to create a Web page
named Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html>
...
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblHeader" runat="server"></asp:Label>
<asp:Label ID="lbFooter" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
You need to dynamically add the UserCtrl.ascx control between the lblHeader and lblFooter Label controls.
What should you do?
A Write the following code segment in the Init event of the Default.aspx Web page:
Control ctrl = LoadControl("UserCtrl.ascx");
this.Controls.AddAt(1, ctrl);
B Write the following code segment in the Init event of the Default.aspx Web page.
Control ctrl = LoadControl("UserCtrl.ascx");
lblHeader.Controls.Add(ctrl);
C Add a Literal control named Ltrl between the lblHeader and lblFooter label controls.
Write the following code segment in the Init event of the Default.aspx Web page:
Control ctrl = LoadControl("UserCtrl.ascx");
D Add a PlaceHolder control named PlHldr between the lblHeader and lblFooter label controls.
Write the following code segment in the Init event of the Default.aspx Web page:
Control ctrl = LoadControl("UserCtrl.ascx");
PlHldr.Controls.Add(ctrl);