Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Nepid7
N
Nepid7
Community Contributor
Quizzes Created: 1 | Total Attempts: 267
| Attempts: 267 | Questions: 6
Please wait...
Question 1 / 6
0 %
0/100
Score 0/100
1. 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.

DataSourceID="SqlDataSource1"ItemDataBound="rptData_ItemDataBound">


Text='<%# Eval("QuantityOnHand") %>' />


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. (Line numbers
are included for reference only.)
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?

Explanation

The code segment should be inserted at line 04 is "Label lbl = e.Item.FindControl("lblQuantity") as Label;". This is because the e.Item.FindControl() method is used to find the control with the ID "lblQuantity" within the current RepeaterItem. By using this method, we can retrieve a reference to the lblQuantity Label control and assign it to the variable lbl.

Submit
Please wait...
About This Quiz
Asp.Net Quizzes & Trivia

This quiz tests knowledge on ASP. NET application development using. NET Framework 3.5, focusing on dynamic control handling, data binding, and custom control creation.

Personalize your quiz and earn a certificate with your name on it!
2. 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" %>

...




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

Explanation

not-available-via-ai

Submit
3.  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. (Line numbers are included for
reference only.)
01 &lt;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?

Explanation

The correct answer is to insert the code segment at line 06 and line 02. This code segment adds an event handler called "FmtClr" to the ListView control's ItemDataBound event. This event is triggered for each item in the ListView control when it is data bound. Inside the event handler, the LineTotalLabel control is found using the FindControl method and its Text property is checked for its length. If the length is greater than 7, the ForeColor property of the control is set to Color.Red, otherwise it is set to Color.Black. This ensures that when the size of the LineTotal column value is greater than seven characters, the column is displayed in red color.

Submit
4. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. You create a composite custom control named MyControl. You need to add an instance of the OrderFormData control to the MyControl control. Which code segment should you use?

Explanation

The correct answer is "protected override void CreateChildControls() {
Controls.Clear();
OrderFormData oFData = new OrderFormData("OrderForm");
Controls.Add(oFData);
}"

This is the correct code segment to use because the CreateChildControls method is responsible for creating the child controls of the composite control. In this code segment, the method is overridden and the existing controls are cleared using the Controls.Clear() method. Then, an instance of the OrderFormData control is created and added to the Controls collection of the MyControl control using the Controls.Add() method. This ensures that the OrderFormData control is added as a child control of the MyControl control.

Submit
5. 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.

oncheckedchanged="Chk_CheckedChanged" AutoPostBack="true" />

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?

Explanation

The correct method to add to the Web page is protected override void LoadViewState(object savedState). This method is responsible for loading the previously saved view state of the page and its controls. By overriding this method and calling the LoadControls() method within it, the user control will be dynamically recreated during postback and its state will be retained. This ensures that the user control meets the given requirements.

Submit
6. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create the following controls:
¡¤A composite custom control named MyControl.
¡¤A templated custom control named OrderFormData.
You write the following code segment to override the method named CreateChildControls() in the
MyControl class. (Line numbers are included for reference only.)
01 protected override void
02 CreateChildControls() {
03 Controls.Clear();
04 OrderFormData oFData = new
05 ?OrderFormData("OrderForm");
06
07 }
You need to add the OrderFormData control to the MyControl control.
Which code segment should you insert at line 06?

Explanation

not-available-via-ai

Submit
View My Results

Quiz Review Timeline (Updated): Mar 19, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 19, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 18, 2009
    Quiz Created by
    Nepid7
Cancel
  • All
    All (6)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
You create a Microsoft ASP.NET application by using the Microsoft .NET...
You create a Microsoft ASP.NET application by using the Microsoft .NET...
 You create a Microsoft ASP.NET application by using the...
You create a Microsoft ASP.NET application by using the Microsoft .NET...
You create a Microsoft ASP.NET application by using the Microsoft .NET...
You create a Microsoft ASP.NET application by using the Microsoft .NET...
Alert!

Advertisement