单项选择题
You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. You create two user controls named UserCtrlA.ascx and UserCtrlB.ascx. The user controls postback to the server.
You create a new Web page that has the following ASPX code:
<asp:CheckBox ID="Chk" runat="server"
oncheckedchanged="Chk_CheckedChanged"
AutoPostBack="true" />
<asp:PlaceHolder ID="PlHolder" runat="server"></asp:PlaceHolder>
To dynamically create the user controls, you write the following code segment for the Web page: public void LoadControls()
{
if (ViewState["CtrlA"] != null)
{
Control c;
if ((bool)ViewState["CtrlA"] == true)
{
c = LoadControl("UserCtrlA.ascx");
} else {
c = LoadControl("UserCtrlB.ascx");
}
c.ID = "Ctrl";
PlHolder.Controls.Add(c);
}
}
protected void Chk_CheckedChanged(object sender, EventArgs e)
{
ViewState["CtrlA"] = Chk.Checked; PlHolder.Controls.Clear();
LoadControls();
}
You need to ensure that the user control that is displayed meets the following requirements: It is recreated during postback It retains its state.
Which method should you add to the Web page?()
A.A
B.B
C.C
D.D
相关考题
-
单项选择题
You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. You create a Web form and add the following code fragment: <asp:Repeater ID="rptData" runat="server" DataSourceID="SqlDataSource1" ItemDataBound="rptData_ItemDataBound"> <ItemTemplate> <asp:Label ID="lblQuantity" runat="server" Text=’<%# Eval("QuantityOnHand") %>’ /> </ItemTemplate> </asp:Repeater> The SqlDataSource1 DataSource control retrieves the Quantity column values from a table named Products. You write the following code segment to create the rptData_ItemDataBound event handler: 01 protected void rptData_ItemDataBound(object sender, 02 RepeaterItemEventArgs e) 03 { 04 05 if(lbl != null) 06 if(int.Parse(lbl.Text) < 10) 07 lbl.ForeColor = Color.Red; 08 } You need to retrieve a reference to the lblQuantity Label control into a variable named lbl. Which code segment should you insert at line 04? ()
A.Label lbl = Page.FindControl("lblQuantity") as Label;
B.Label lbl = e.Item.FindControl("lblQuantity") as Label;
C.Label lbl = rptData.FindControl("lblQuantity") as Label;
D.Label lbl = e.Item.Parent.FindControl("lblQuantity") as Label; -
单项选择题
You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. You define the following class: public class Product { public decimal Price { get; set; } } Your application contains a Web form with a Label control named lblPrice. You use a StringReader variable named xmlStream to access the following XML fragment: <Product> <Price>35</Price> </Product> You need to display the price of the product from the XML fragment in the lblPrice Label control. Which code segment should you use?()
A.A
B.B
C.C
D.D -
单项选择题
You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. You create a Web page that contains the following two XML fragments: 01 <script runat="server"> 02 03 </script> 04 <asp:ListView ID="ListView1" runat="server" 05 DataSourceID="SqlDataSource1" 06 07 > 08 <ItemTemplate> 09 <td> 10 <asp:Label ID="LineTotalLabel" runat="server" 11 Text=’<%# Eval("LineTotal") %>’ /> 12 </td> 13 </ItemTemplate> The SqlDataSource1 object retrieves the data from a Microsoft SQL Server 2005 database table. The database table has a column named LineTotal. You need to ensure that when the size of the LineTotal column value is greater than seven characters, the column is displayed in red color. What should you do?()
A.A
B.B
C.C
D.D
