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

Question: You are appointed as a senior developer at Company.com. Company.com makes use of Microsoft .NET Framework 3.5. You create a Microsoft ASP.NET application that includes a Web page with a Calendar control named cal1. The cal1 control is declared as follws:

<asp:Calendar EnableViewState="false"ID="cal1" runat="server" /> 

The code-behind file of the Web page contains the subsequent code:

Private Sub LoadDate(ByVal sender As Object, ByVal e As EventArgs)
If IsPostBack Then
cal1.SelectedDate = DirectCast(ViewState("date"), DateTime)
End If
End Sub
Private Sub sDate(ByVal sender As Object, ByVal e As EventArgs)
ViewState("date") = cal1.SelectedDate
End Sub 

You receive an instruction from management to make sure that the cal1 Calendar control retains the selected date. You thus need to determine the appropriate code segment.
What should you identify?

  1. You should consider inserting the following code segment:
    AddHandler Me.Init, AddressOf LoadDate
    AddHandler Me.Unload, AddressOf sDate
  2. You should consider inserting the following code segment:
    AddHandler Me.Load, AddressOf LoadDate
    AddHandler Me.PreRender, AddressOf sDate
  3. You should consider inserting the following code segment:
    AddHandler Me.Init, AddressOf LoadDate
    AddHandler Me.PreRender, AddressOf sDate
  4. You should consider inserting the following code segment:
    AddHandler Me.Load, AddressOf LoadDate
    AddHandler Me.Unload, AddressOf sDate

Correct Answer: 2


Question: You work as a Web Developer at Company.com. You are currently making use of Microsoft ASP.NET 3.5 to create a Web application. You create a base user control named CKMenuUserControl. You notice that eight user controls originated from CKMenuUserControl. You add a PlaceHolder control named menuPlaceHolder to the page. You create the following method in order to load one of the 8 user controls into menuPlaceHolder:

private void DisplayMenuUserControl(string userControlPath)
{
} 

You notice that the path of the user control to load is passed as a parameter to the method. You want to write code in order to load the user control. You need to ensure that your choice will support CKMenuUserControl-derived user controls without the need to re-implement the method. Determine the code segment that would achieve this?

  1. AssignmentUserControl control = new AssignmentUserControl();
    LoadControl(userControlPath);
    menuPlaceHolder.Controls.Add(control);
  2. AssignmentUserControl control = new AssignmentUserControl();
    control.ID = userControlPath;
    menuPlaceHolder.Controls.Add(control);
  3. Control control menuPlaceHolder.FindControl(userControlPath);
    menuPlaceHolder.Controls.Add(control);
  4. Control control = LoadControl(userControlPath);
    menuPlaceHolder.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 application that uses Microsoft ASP.NET 3.5. You are busy loading a user control into a container on the page. You need to make sure that the control is loaded during the correct page event. This is to ensure that the control will participate in post back data processing and validation. You need to determine a way to accomplish this.
What should you do?

  1. You should handle the PreRender event and load the user control.
  2. You should handle the Init event and load the user control.
  3. You should handle the Load event and load the user control.
  4. You should handle the SaveStateComplete event and load the user control.

Correct Answer: 2


Question: You work as a Web Developer at Company.com. You make use of Microsoft ASP.NET 3.5 in order to create a Web application. The code below is defined in a code-behind file for a user control named Company.ascx. The file exists in the root application directory:

[PartialCaching(20)]
public partial class Company : UserControl
{
public string Message
{
get
{
string message = (string)ViewState["Message"] ?? string.Empty;
return message;
}
set
{
ViewState["Message"] = value;
}
}
} 

You have to ensure that the Company.com user control is loaded programmatically as well as setting the Message property to the string Welcome. Identify the code segment that will accomplish this?

  1. You should consider using:
    UserControl control = new UserControl();
    control.LoadControl(“~/Company.ascx”);
    Company header = control as Company;
    if (Company != null)
    {
    Company.Message = “Welcome”;
    }
  2. You should consider using:
    Company Company = (Company)LoadControl(“~/Company.ascx”);
    Company.Message = “Welcome”;
  3. You should consider using:
    Company Company = new Company();
    Company.LoadControl(“~/Company.ascx”);
    Company.Message = “Welcome”;
  4. You should consider using:
    PartialCachingControl control = (PartialCachingControl) LoadControl(“~/Company.ascx”);
    Company header = control.CachedControl as Company;
    if (Company != null)
    {
    Company.Message = “Welcome”;
    }

Correct Answer: 4


Question: You work as a Web Application Developer. You make use of Microsoft .NET Framework 3.5 to create a ASP.NET AJAX enabled application. You add a client script function to the application by writing the code below: (The line numbers is included for reference purposes)
1 function updCrtl(lblId, updText) {
2 var myLbl = $find(lblId);
3 myLbl.innerHTML = updText;
4 }
This client script function will make use of and will be used to update the text of any Label control in the Web form. Whilst testing the function you detect that the Label controls is not updated. You receive a “‘null’ is null or not an object” JavaScript error message in the browser. You need to determine a way to resolve the error.
What should you do?

  1. Your best option would be to replace line 2 of the code with:
    var myLbl = Sys.UI.DomElement.getElementById($get(lblId));
  2. Your best option would be to replace line 2 of the code with:
    var myLbl = $get(lblId);
  3. Your best option would be to replace line 2 of the code with:
    var myLbl = Sys.UI.DomElement.getElementById($find(lblId));
  4. Your best option would be to replace line 3 of the code with:
    myLbl.innerText = updText;

Correct Answer: 2

Tagged . Bookmark the permalink.

Leave a Reply