Exam 70-562 : Microsoft .NET Framework 3.5, ASP.NET Application Development – 10

Question: You work as an application developer at Company.com. You are in the process of creating an ASP.NET application using Microsoft .NET Framework 3.5. You application contains a Web page named Index.aspx that has the code below:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="_Index" %>
<html>
...
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblTitle" runat="server"></asp:Label>
<asp:Label ID="lbSub" runat="server"></asp:Label>
</div>
</form>
</body>
</html> 

You create a user control named _contr.ascx. You receive an instruction from management to dynamically add the _contr.ascx control between the two Label controls. You need to determine a way to achieve this.
What should you do?

  1. Your best option would be to write the code below in the Init event of the Index.aspx Web page:
    Control _control = LoadControl(“_contr.ascx”);
    lblTitle.Controls.Add(_control);
  2. Your best option would be to write the code below in the Init event of the Index.aspx Web page:
    Control _control = LoadControl(“_contr.ascx”);
    this.Controls.AddAt(1, _control);
  3. Your best option would be to add a Literal control named KingLtrl between the lblTitle and lblSub myLbl controls.
    Thereafter the Control _control = LoadControl(“_contr.ascx”) code should be written in the Init event of the Index.aspx Web page.
  4. Your best option would be to add a PlaceHolder control named CKHolder between the lblTitle and lblSub myLbl controls.
    Thereafter code below should be written in the Init event of the Index.aspx Web page:
    Control _control = LoadControl(“_contr.ascx”);
    CKHolder.Controls.Add(_control);

Correct Answer: 4


Question: You work as a Web Developer at Company.com. You are in the process of creating a Web site using Microsoft ASP.NET 3.5. You create a server control named ScoreChart in a file named CKResults.cs. CKResults.cs is contained in the App_Code folder. The Chart class is part of the Company.WebControls namespace. You want to configure a page to use the control declaratively. What page directive should you add to the page?

  1. <%@ Register TagPrefix=”ck” Namespace=”Company.WebControls”/>
  2. <%@ Reference Control=”Company.WebControls. ScoreChart” VirtualPath=”~/App_Code”/>
  3. <%@ Reference Control=”Company.WebControls.ScoreChart, App_Code”/>
  4. <%@ Register TagName=”ScoreChart” Namespace=”Company.WebControls” Assembly=”App_Code”/>

Correct Answer: 1


Question: You are part of the Web Developer team at Company.com. You are in the process of creating a custom control in Microsoft ASP.NET 3.5 for Company.com’s Web application. The control is implemented as follows:

public class Circle : Control
{
public double Radius
{
get
{
return (double)ViewState["Radius"] ?? 0.0;
}
set
{
ViewState["Radius"] = value;
}
}
} 

You have to extend the control in order for the Radius property to be set from Java Script. What should you do?

  1. You should add a method named GetRadius that returns the Radius property. Then the ScriptMethod feature should be applied to the method.
  2. You should implement the IScriptControl interface.
  3. You should derive the class from ScriptControlDescriptor instead of Control.
  4. You should apply the ScriptService feature to the class.

Correct Answer: 2


Question: You work as a Web Developer at Company.com. You make use of Microsoft ASP.NET 3.5 to create a Web application. In order to create a template control you write the following code:

[ParseChildren(true)]
public class ExamViewer : Control, INamingContainer
{
public Exam Exam {get; set; }
[TemplateContainer(typeof(ExamTemplateContainer))]
public ITemplate ExamTemplate {get; set; }
protected override void CreateChildControls()
{
}
}
public class ExamTemplateContainer : Control, INamingContainer
{
public Exam Exam {get; set; }
}

You decide to implement the CreateChildControls method of the ExamViewer class. This to ensure that the content indicated in the ExamTemplate property is rendered by the ExamViewer control. You need to determine the appropriate code segment that will accomplish that.
Which code should you use?

  1. You should consider using:
    if (this.ExamTemplate == null)
    {
    this.Controls.Clear();
    ExamTemplateContainer container = new ExamTemplateContainer()
    {
    Exam = this.Exam;
    };
    this.Controls.Add(container);
    }
  2. You should consider using:
    if (this.ExamTemplate == null)
    {
    this.Controls.Clear();
    ExamTemplateContainer container = new ExamTemplateContainer()
    {
    Exam = this.Exam;
    };
    this.ExamTemplate.InstantiateIn(container);
    this.Controls.Add(container);
    }
  3. You should consider using:
    if (this.ExamTemplate != null)
    {
    this.Controls.Clear();
    ExamTemplateContainer container = new ExamTemplateContainer()
    {
    Exam = this.Exam;
    };
    this.Controls.Add(container);
    }
  4. You should consider using:
    if (this.ExamTemplate != null)
    {
    this.Controls.Clear();
    ExamTemplateContainer container = new ExamTemplateContainer()
    {
    Exam = this.Exam;
    };
    this.ExamTemplate.InstantiateIn(container);
    this.Controls.Add(container);
    }

Correct Answer: 4


Question: You work as the application developer at Company.com. You use Microsoft .NET Framework 3.5 to create an application. You create a composite custom control named _compCtr and a templated custom control named _tmplCtr. You also write code to override the AddControls() method in _compCtr. You thus write the subsequent code segment. (The line numbers is included for reference purposes)
1 protected override void
2 AdddControls() {
3 Controls.Clear();
4 _tmplCtr addCData = new
5 ?_tmplCtr (“Form1”);
6
7 }
To accomplish this you need to add _tmplCtr control to _compCtr.
What should you do?

  1. You should consider inserting the subsequent code segment at line 6:
    this.TemplateControl = (TemplateControl)Template;
    addCData.TemplateControl = (TemplateControl)Template;
    Controls.Add(addCData);
  2. You should consider inserting the subsequent code segment at line 6:
    Controls.Add(addCData);
  3. You should consider inserting the subsequent code segment at line 6:
    Controls.Add(addCData);
    this.Controls.Add(addCData);
  4. You should consider inserting the subsequent code segment at line 6:
    Template.InstantiateIn(this);
    Template.InstantiateIn(addCData);

Correct Answer: 4

Tagged . Bookmark the permalink.

Leave a Reply