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

Question: You work as a Web Application Developer. You are currently using Microsoft .NET Framework 3.5 to create an ASP.NET application. You receive a request from management to create a custom control for the marketing department. You name this control _customForm. You then write the subsequent code:

Public Delegate Sub _customFormEventHandler(ByVal e As EventArgs)
Private Shared ReadOnly _customFormKey As New Object()
public event _customFormEventHandler
Public Custom Event Check_customForm As _customFormEventHandler
AddHandler(ByVal value As _customFormEventHandler)
Events.[AddHandler](_customFormKey, value)
End AddHandler
RemoveHandler(ByVal value As _customFormEventHandler)
Events.[RemoveHandler](_customFormKey, value)
End RemoveHandler
RaiseEvent(ByVal e As EventArgs)
End RaiseEvent
End Event 

To ensure productivity you need to make sure that the _customForm control is able to raise the Check_customForm event. You thus need to determine the appropriate method that will achieve this.
What should you do?

  1. This can be accomplished using:
    Private check_customForm As New _customFormEventHandler(AddressOf _
    check_customFormCallBack)
    Protected Overridable Sub OnCheck_customForm(ByVal e As EventArgs)
    If check_customForm IsNot Nothing Then
    RaiseBubbleEvent(check_customForm, e)
    End If
    End Sub
  2. This can be accomplished using:
    Protected Overridable Sub OnCheck_customForm(ByVal e As EventArgs)
    Dim check_customForm As _customFormEventHandler = _
    DirectCast(Events(GetType(_customFormEventHandler)), _customFormEventHandler)
    RaiseEvent Check_customForm(e)
    End Sub
  3. This can be accomplished using:
    Private check_customForm As New _customFormEventHandler(AddressOf _
    check_customFormCallBack)
    Protected Overridable Sub OnCheck_customForm(ByVal e As EventArgs)
    If check_customForm IsNot Nothing Then
    check_customForm(e)
    End If
    End Sub
  4. This can be accomplished using:
    Protected Overridable Sub OnCheck_customForm(ByVal e As EventArgs)
    Dim check_customForm As _customFormEventHandler = _
    TryCast(Events(_customFormKey), _customFormEventHandler)
    RaiseEvent Check_customForm(e)
    End Sub

Correct Answer: 4


Question: You work as a technician at Company.com. You make use of Microsoft .NET Framework 3.5 to create an ASP.NET application. You receive an instruction from the administrator to create a customcontrol. You name this control CKOrderForm. You thus write the code below:

public delegate void
CheckOrderFormEventHandler(EventArgs e);
private static readonly object CheckOrderFormKey = new object();
public event CheckOrderFormEventHandler
CheckOrderForm {
add {
Events.AddHandler(CheckOrderFormKey, value);
}
remove {
Events.RemoveHandler(CheckOrderFormKey,
value);
}
} 

You have to make sure that CKOrderForm is able to raise the CheckOrderForm event. You thus need to determine the appropriate method that will accomplish this.
What should you do?

  1. You should consider using:
    protected virtual void OnCheckOrderForm(EventArgs e) {
    CheckOrderFormEventHandler checkOrderForm = (CheckOrderFormEventHandler)Events[
    typeof(CheckOrderFormEventHandler)];
    if (checkOrderForm != null)
    checkOrderForm(e);
    }
  2. You should consider using:
    protected virtual void OnCheckOrderForm(EventArgs e) {
    CheckOrderFormEventHandler checkOrderForm =Events[CheckOrderFormKey] as
    CheckOrderFormEventHandler;
    if (checkOrderForm != null)
    checkOrderForm(e);
    }
  3. You should consider using:
    CheckOrderFormEventHandler checkOrderForm =
    new CheckOrderFormEventHandler(checkOrderFormCallBack);
    protected virtual void OnCheckOrderForm(EventArgs e) {
    if (checkOrderForm != null)
    checkOrderForm(e);
    }
  4. You should consider using:
    CheckOrderFormEventHandler checkOrderForm =
    new CheckOrderFormEventHandler(checkOrderFormCallBack);
    protected virtual void OnCheckOrderForm(EventArgs e) {
    if (checkOrderForm != null)
    RaiseBubbleEvent(checkOrderForm, e);
    }

Correct Answer: 2


Question: You work as an application developer at Company.com. You are in the process of creating an ASP.NET application in .NET Framework 3.5. You create a custom control named CKControl. Management wants you to include an instance of the FormData control to CKControl. You thus need to determine the appropriate code segment that will accomplish this. What should you do?

  1. You should consider using:
    protected override void
    RenderContents(HtmlTextWriter writer) {
    FormData oFData = new FormData(“Form1”);
    oFData.RenderControl(writer);
    }
  2. You should consider using:
    protected override ControlCollection
    CreateControlCollection() {
    ControlCollection controls = new ControlCollection(this);
    FormData oFData = new FormData(“Form1”);
    controls.Add(oFData);
    return controls;
    }
  3. You should consider using:
    protected override void ChildControls() {
    Controls.Clear();
    FormData oFData = new FormData(“Form1”);
    oFData.ChildControls();
    if (!ChildControlsCreated)
    CreateChildControls();
    }
  4. You should consider using:
    protected override void CreateChildControls() {
    Controls.Clear();
    FormData oFData = new FormData(“Form1”);
    Controls.Add(oFData);
    }

Correct Answer: 4


Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application that uses Microsoft ASP.NET 3.5. You add the following controls to a web form:

<asp:TextBox ID="_certTextBox" runat="server"/>
<asp:RequiredFieldValidator ID="_certRequiredValidator" runat="server" ControlToValidate="_certTextBox" ErrorMessage="A Certification is required." ValidationGroup="Cert"/>
<asp:TextBox ID="_examTextBox" runat="server"/>
<asp:RequiredFieldValidator ID="_examRequiredValidator" runat="server" ControlToValidate="_examTextBox" ErrorMessage="An Exam number is required." ValidationGroup="Exam"/>
<asp:RangeValidator ID="_examRangeValidator" runat="server" MinimumValue="70-001" MaximumValue="70-999" ControlToValidate="_examTextBox" ErrorMessage="Exam number is invalid." ValidationGroup="Exam"/>

You have to make sure that you are able to validate the _examTextBox textbox. If the data is valid, you want a method named AddExam to be called. What code should you use?

  1. You should use:
    Context[“ValidationGroup”] = “Exam”;
    Page.Validate();
    if (Page.IsValid)
    {
    AddExam();
    }
  2. You should use:
    Context[“ValidationGroup”] = “Exam”;
    Page.Validate();
    bool isValid = true;
    foreach (IValidator validator in Page.Validators)
    {
    if (!validator.IsValid)
    {
    isValid = false;
    break;
    }
    }
    if (isValid)
    {
    AddExam();
    }
  3. You should use:
    Page.Validate(“Exam”);
    if (Page.IsValid)
    {
    AddExam();
    }
  4. You should use:
    Page.Validate(“Exam”);
    bool isValid = true;
    foreach (IValidator validator in Page.Validators)
    {
    if (!validator.IsValid)
    {
    isValid = false;
    break;
    }
    }
    if (isValid)
    {
    AddExam();
    }

Correct Answer: 3


Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application that uses Microsoft ASP.NET 3.5. The following markup should be added to a page:

<cc:Question ID="_question" runat="server" QuestionID="Q001"/>
<asp:RequiredFieldValidator ID="_validator" runat="server" ControlToValidate="_question" ErrorMessage="You must answer this question."/> 

The Question control is a custom server control that originates from the WebControl. This control does not implement any interfaces. The following characteristics are applied to the control’s class: ToolboxData, Designer, and DefaultProperty.
You have to make sure that the Question control is able to participate in server-side validation on this page. What should you do?

  1. You should consider modifying the Question control’s class in order to implement IValidator.
  2. You should consider setting the ValidationGroup property of the RequiredFieldValidator control to UserControl.
  3. You should apply the ValidationProperty feature to the Question control’s class.
  4. You should consider setting the InitialValue property of the RequiredFieldValidator control to an empty string.

Correct Answer: 3

Tagged . Bookmark the permalink.

Leave a Reply