What should you do to dynamically add the UserCtrl.ascx control between the lblHeader and lblFooter Label controls?

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="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" 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?

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=”VB” AutoEventWireup=”true” CodeFile=”Default.aspx.vb” 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.
Dim ctrl As Control = LoadControl(“UserCtrl.ascx”)
Me.Controls.AddAt(1, ctrl)

B.
Write the following code segment in the Init event of the Default.aspx Web page.
Dim ctrl As Control = 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.
Dim ctrl As Control = 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.
Dim ctrl As Control = LoadControl(“UserCtrl.ascx”)
PlHldr.Controls.Add(ctrl)



Leave a Reply 0

Your email address will not be published. Required fields are marked *