70 562 .Net 3.5 Framework

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Nepid7
N
Nepid7
Community Contributor
Quizzes Created: 1 | Total Attempts: 265
Questions: 6 | Attempts: 265

SettingsSettingsSettings
DotNET Quizzes & Trivia

TS: MS. NET Framework 3.5,
ASP. NET Application Development


Questions and Answers
  • 1. 

     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 forreference only.)01 &lt;Script runat="server">0203 /script>04 asp:ListView ID="ListView1" runat="server"05 DataSourceID="SqlDataSource1"0607 >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. Thedatabase table has a column named LineTotal.You need to ensure that when the size of the LineTotal column value is greater than seven characters, thecolumn is displayed in red color.What should you do?

    • A.

      Insert the following code segment at line 06. OnItemDataBound="FmtClr" Insert the following code segment at line 02. protected void FmtClr (object sender, ListViewItemEventArgs e) { Label LineTotal = (Label) e.Item.FindControl("LineTotalLabel"); if ( LineTotal.Text.Length > 7) { LineTotal.ForeColor = Color.Red; } else {LineTotal.ForeColor = Color.Black; } }

    • B.

      Insert the following code segment at line 06. OnItemDataBound="FmtClr" Insert the following code segment at line 02. protected void FmtClr (object sender, ListViewItemEventArgs e) { Label LineTotal = (Label) e.Item.FindControl("LineTotal"); if ( LineTotal.Text.Length > 7) {LineTotal.ForeColor = Color.Red; } else {LineTotal.ForeColor = Color.Black; } }

    • C.

      Insert the following code segment at line 06. OnDataBinding="FmtClr" Insert the following code segment at line 02. protected void FmtClr(object sender, EventArgs e) { Label LineTotal = new Label(); LineTotal.ID = "LineTotal"; if ( LineTotal.Text.Length > 7) {LineTotal.ForeColor = Color.Red; } else { LineTotal.ForeColor = Color.Black; } }

    • D.

      Insert the following code segment at line 06. OnDataBound="FmtClr" Insert the following code segment at line 02. protected void FmtClr(object sender, EventArgs e) { Label LineTotal = new Label(); LineTotal.ID = "LineTotalLabel"; if ( LineTotal.Text.Length > 7) {LineTotal.ForeColor = Color.Red; } else {LineTotal.ForeColor = Color.Black; } }

    Correct Answer
    A. Insert the following code segment at line 06. OnItemDataBound="FmtClr" Insert the following code segment at line 02. protected void FmtClr (object sender, ListViewItemEventArgs e) { Label LineTotal = (Label) e.Item.FindControl("LineTotalLabel"); if ( LineTotal.Text.Length > 7) { LineTotal.ForeColor = Color.Red; } else {LineTotal.ForeColor = Color.Black; } }
    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.

    Rate this question:

  • 2. 

    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 namedProducts.You write the following code segment to create the rptData_ItemDataBound event handler. (Line numbersare included for reference only.)01 protected void rptData_ItemDataBound(object sender,02 RepeaterItemEventArgs e)03 {0405 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;

    Correct Answer
    B. Label lbl = e.Item.FindControl("lblQuantity") as Label;
    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.

    Rate this question:

  • 3. 

    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 createa 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 Labelcontrols.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);

    Correct Answer
    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);
  • 4. 

    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 tothe 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?

    • A.

      Protected override object SaveViewState() { LoadControls(); return base.SaveViewState(); }

    • B.

      Protected override void Render(HtmlTextWriter writer) { LoadControls(); base.Render(writer); }

    • C.

      Protected override void OnLoadComplete(EventArgs e) { base.OnLoadComplete(e); LoadControls(); }

    • D.

      Protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); LoadControls(); }

    Correct Answer
    D. Protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); LoadControls(); }
    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.

    Rate this question:

  • 5. 

    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 theMyControl class. (Line numbers are included for reference only.)01 protected override void02 CreateChildControls() {03 Controls.Clear();04 OrderFormData oFData = new05 ?OrderFormData("OrderForm");0607 }You need to add the OrderFormData control to the MyControl control.Which code segment should you insert at line 06?

    • A.

      Controls.Add(oFData);

    • B.

      Template.InstantiateIn(this); Template.InstantiateIn(oFData);

    • C.

      Controls.Add(oFData); this.Controls.Add(oFData);

    • D.

      This.TemplateControl = (TemplateControl)Template; oFData.TemplateControl = (TemplateControl)Template; Controls.Add(oFData);

    Correct Answer
    B. Template.InstantiateIn(this); Template.InstantiateIn(oFData);
  • 6. 

    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?

    • A.

      Protected override void CreateChildControls() { Controls.Clear(); OrderFormData oFData = new OrderFormData("OrderForm"); Controls.Add(oFData); }

    • B.

      Protected override void RenderContents(HtmlTextWriter writer) { OrderFormData oFData = new OrderFormData("OrderForm"); oFData.RenderControl(writer); }

    • C.

      Protected override void EnsureChildControls() { Controls.Clear(); OrderFormData oFData = new OrderFormData("OrderForm"); oFData.EnsureChildControls(); if (!ChildControlsCreated) CreateChildControls(); }

    • D.

      Protected override ControlCollection CreateControlCollection() { ControlCollection controls = new ControlCollection(this); OrderFormData oFData = new OrderFormData("OrderForm"); controls.Add(oFData); return controls; }

    Correct Answer
    A. Protected override void CreateChildControls() { Controls.Clear(); OrderFormData oFData = new OrderFormData("OrderForm"); Controls.Add(oFData); }
    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.

    Rate this question:

Quiz Review Timeline +

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

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.