188
Question 1 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. You are not using an exception management framework in the application. However, the application must automatically log all unhandled exceptions to the event log. You need to configure the Web.config file accordingly. Which configuration should you use? <healthMonitoring enabled="true"/> <deployment retail="true"/> <customErrors mode="On"/> <trace enabled="true"/> Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-051 Jump to Question ID Question 1 Explanation: You should set the enabled attribute of the healthMonitoring element to true. This enables health monitoring. Health monitoring defines events to be monitored, providers that deliver the events, and rules that map events to providers. The root Web.config is configured to deliver all unhandled exceptions to the event log. However, it sets the enabled attribute to false, which is why you must set it to true in the application's Web.config file. You should not configure the customErrors element. This element allows you to specify how the application displays unhandled exceptions.

70562 (1)

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: 70562 (1)

Question 1 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You are not using an exception management framework in the application. However, the application must automatically log all unhandled exceptions to the event log.

You need to configure the Web.config file accordingly.

Which configuration should you use?

<healthMonitoring enabled="true"/>

<deployment retail="true"/>

<customErrors mode="On"/>

<trace enabled="true"/>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-051 Jump to Question ID

Question 1 Explanation:

You should set the enabled attribute of the healthMonitoring element to true. This

enables health monitoring. Health monitoring defines events to be monitored, providers

that deliver the events, and rules that map events to providers. The root Web.config is

configured to deliver all unhandled exceptions to the event log. However, it sets the

enabled attribute to false, which is why you must set it to true in the application's

Web.config file.

You should not configure the customErrors element. This element allows you to specify

how the application displays unhandled exceptions.

Page 2: 70562 (1)

You should not configure the trace element. This element allows you to enable and

configure ASP.NET tracing.

You should not configure the deployment element. This element only has meaning in

the machine.config file. When the retail attribute is set to true, features such as custom

errors, ASP.NET tracing, and debugging are disabled.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.6 Monitor Web applications.

2. You create a Web site by using Microsoft ASP.NET 3.5. You create the following class

in a separate code file:

public static class ChartColors

{

public static Color NormalActivityColor = Color.Green;

public static Color WarningActivityColor = Color.Yellow;

public static Color ErrorActivityColor = Color.Red;

public static Color GetRandomColor()

{

Random random = new Random((int)DateTime.Now.Ticks);

int randomArgbValue = random.Next();

Color color = Color.FromArgb(255, Color.FromArgb(randomArgbValue));

return color;

}

}

You need to configure the Web site project so that this class can be consumed by the

Web site.

Page 3: 70562 (1)

What should you do?

Add the file to the App_Code folder of the project.

Add a Register directive that references the file to each page that consumes the class.

Reference the file in the assemblies section of the Web.config file.

Reference the file in the httpHandlers section of the Web.config file.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-004 Jump to Question ID

Question 2 Explanation:

You should add the file to the App_Code folder of the project. The App_Code folder

allows you to store utility classes for users in a Web site project. Code placed in this

folder is dynamically compiled into an assembly.

You should not reference the file in the assemblies section of the Web.config file. You

should reference binary assemblies in the assemblies section. In this scenario, the code

file is not a binary assembly because the code is not yet compiled.

You should not add a Register directive that references the file to each page that

consumes the class. You should use the Register directive to reference files containing

user controls or assemblies containing server controls.

You should not reference the file in the httpHandlers section of the Web.config file. You

should use the httpHandlers section to reference classes that implement the

IHttpHandler interface. In this scenario, the ChartColors class does not implement an

interface.

Page 4: 70562 (1)

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.4 Implement business objects and utility classes.

References:

Question 3 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following code exists in the code-behind file for a page:

private void Process(Location[] locations) { if (_scriptManager.IsInAsyncPostBack) { JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); string jsonArray = jsonSerializer.Serialize(locations); _scriptManager.RegisterDataItem(_locationGridView, jsonArray, true); } }

This code creates a JavaScript Object Notation (JSON) array from an array of Location instances. The _locationGridView control is contained within four nested naming containers on the page.

You need to access the JSON array from client script.

Which code segment should you use?

Page 5: 70562 (1)

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(OnLoaded);function OnLoaded(sender, args){var dataItems = args.get_dataItems();var locations = dataItems['<%= _locationGridView.ClientID %>'];}

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(OnRequest);function OnRequest(sender, args){var dataItems = args.get_postBackElement();var locations = dataItems['_locationGridView'];}

Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(OnLoading);function OnLoading(sender, args){var dataItems = args.get_dataItems();var locations = dataItems['_locationGridView'];}

Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(OnInit);function OnInit(sender, args){var dataItems = args.get_postBackElement();var locations = dataItems['<%= _locationGridView.ClientID %>'];}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-019 Jump to Question ID

Question 3 Explanation:

You should use the following code segment:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(OnLoaded);

function OnLoaded(sender, args)

{

var dataItems = args.get_dataItems();

var locations = dataItems['<%= _locationGridView.ClientID %>'];

}

This code creates an event handler for the pageLoaded Asynchronous JavaScript and

XML (AJAX) event. This event is raised after an AJAX request is completed and page

Page 6: 70562 (1)

regions are updated. The event handler defines a PageLoadedEventArgs parameter that

represents the event arguments. The PageLoadedEventArgs object contains a property

named dataItems that contains all data items registered by the call to the

RegisterDataItem method of the ScriptManager class. The data items are indexed by

the client IDs of the controls that were specified in the call to the RegisterDataItem

method. In this scenario, the code passed the _locationGridView control instance to the

RegisterDataItem method to register a JSON array as a data item. To access this array,

you must use the client ID of the _locationGridView control instance. Because the

_locationGridView control is contained with four nested naming containers, this code

uses the <%= _locationGridView.ClientID %> syntax to obtain the client ID of the

_locationGridView control. When a control is contained within nested naming

containers, its client ID is prefixed with the names of the naming containers.

You should not use the following code segment:

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(OnRequest);

function OnRequest(sender, args)

{

var dataItems = args.get_postBackElement();

var locations = dataItems['_locationGridView'];

}

This code creates an event handler for the beginRequest AJAX event. This event is

raised after an AJAX request is initiated but before the request is sent to the server.

Items registered by using the RegisterDataItem method of the ScriptManager class can

only be accessed in pageLoaded, pageLoading and endRequest events of

PageRequestManager.

You should not use the following code segment:

Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(OnInit);

function OnInit(sender, args)

{

var dataItems = args.get_postBackElement();

var locations = dataItems['<%= _locationGridView.ClientID %>'];

}

This code creates an event handler for the initializeRequest AJAX event. This event is

raised before an AJAX request is initialized. Items registered by using the

RegisterDataItem method of the ScriptManager class can only be accessed in

pageLoaded, pageLoading and endRequest events of PageRequestManager.

You should not use the following code segment:

Page 7: 70562 (1)

Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(OnLoading);

function OnLoading(sender, args)

{

var dataItems = args.get_dataItems();

var locations = dataItems['_locationGridView'];

}

This code creates an event handler for the pageLoading AJAX event. This event is raised

after an AJAX request has completed but before page regions are updated. You can

access registered data items from this event handler. However, this code uses the string

"_locationGridView" to index the data items. According to the scenario, the

_locationGridView control is contained within four nested naming containers on the

page. This means that its client ID is prefixed with the names of the naming containers.

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.2 Interact with the ASP.NET AJAX client-side library.

References:

1. ScriptManager.RegisterDataItem Method (Control, String, Boolean)

Click here for further information

MSDN, Microsoft

2. Sys.WebForms.PageRequestManager pageLoaded Event

Click here for further information

MSDN, Microsoft

3. Sys.WebForms.PageLoadedEventArgs Class

Click here for further information

MSDN, Microsoft

Page 8: 70562 (1)

4. An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET

Click here for further information

MSDN, Microsoft

Question 4 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following markup exists on a page:

<asp:TextBox ID="_titleTextBox" runat="server"/> <asp:Button ID="_button" runat="server" Text="Filter"/> <asp:SqlDataSource ID="_bookDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:Publishing %>" SelectCommand="GetBooks" SelectCommandType="StoredProcedure" FilterExpression="Active=1 AND Title LIKE '{0}%'"> <FilterParameters> <asp:ControlParameter ControlID="_titleTextBox"/> </FilterParameters> </asp:SqlDataSource> <asp:GridView ID="_bookGridView" runat="server" DataSourceID="_bookDataSource"/>

The page retrieves all books in the company's database and displays only the active books. The TextBox control allows you to also filter books by title. When you click the Filter button and do not specify a title, the page does not filter by active books. It displays all books retrieved from the database. If you do not specify a title, you want the page to display only active books.

You need to solve this problem.

What should you do?

Set the Name property of the ControlParameter control.

Set the PropertyName property of the ControlParameter control to Text.

Set the ControlParameter control's ConvertEmptyStringToNull property to false.

Page 9: 70562 (1)

Replace the {0} placeholder in the FilterExpression property with the (?) symbol.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-064 Jump to Question ID

Question 4 Explanation:

You should set the ControlParameter control's ConvertEmptyStringToNull property to

false. When using FilterExpression and FilterParameters, if one of the evaluated values

for the FilterParameters collection is null, then the data will not get filtered at all. To

accommodate this, you should set the ConvertEmptyStringToNull property to false. The

default value of this property is true. This means that if you do not specify a title, the

parameter converts the empty string returned by the Text property of the TextBox

control to null. Setting the value to false will cause the empty string to be passed to the

data source.

You should not replace the {0} placeholder with the (?) symbol. You must use format

placeholders in the FilterExpression property. The value of each parameter in the

FilterParameters collection will replace the format placeholders in the FilterExpression

property when the data is filtered.

You should not set the Name property of the ControlParameter control to solve this

problem. You must set the Name property when using select parameters, insert

parameters, update parameters, or delete parameters when executing SQL commands

that use named parameters, such as @param1.

You should not set the PropertyName property of the ControlParemeter control to Text

to solve this problem. If you do not set the PropertyName property, the

ControlParameter control determines whether the ControlValueProperty attribute is

applied to the control specified by the ControlID property. If so, the ControlParameter

property uses this attribute to obtain the value of the associated control. The

ControlValueProperty attribute applied to the TextBox class specifies Text as the default

property for ControlParameter controls.

Page 10: 70562 (1)

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.4 Implement a DataSource control.

References:

1. SqlDataSource Web Server Control Declarative Syntax

Click here for further information

MSDN, Microsoft

2. Handling Null Database Values Using Data Source Controls

Click here for further information

MSDN, Microsoft

3. Filtering Data Using Data Source Controls

Click here for further information

MSDN, Microsoft

Question 5 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following HTML element exists on an ASP.NET page:

<input type="hidden" name="HiddenField"/>

You need to retrieve the value of the element in the code-behind class.

Which code segment should you use? (Each correct answer presents a

Page 11: 70562 (1)

complete solution. Choose two.)

string value = Application["HiddenField"];

string value = ((HtmlInputHidden)Page.FindControl("HiddenField")).Value;

string value = Request.Params["HiddenField"];

string value = Request.Form["HiddenField"];

string value = Context["HiddenField"];

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-006 Jump to Question ID

Question 5 Explanation:

You should access the HiddenField item from the Request.Form collection. This

collection contains all HTML form fields that are rendered by the page. This includes

HTML Input elements.

Alternatively, you can access the HiddenField item of the Request.Params collection.

This collection contains HTML form fields, query string paramers, HTTP server variables,

and cookies.

You should not access items of the current HttpApplicationState instance. An

HttpApplicationState instance is created for each instance of an ASP.NET application.

However, HTML form fields are not automatically stored in HttpContext instances.

You should not access items of the current HttpContext instance. An HttpContext

instance is created during each HTTP request to an application. However, HTML form

fields are not automatically stored in HttpContext instances.

You should not call the FindControl method of the Page class to retrieve the HTML Input

element. The FindControl method finds server controls only. In this scenario, the HTML

Input element is not a server control because it is missing the runat=server attribute.

Page 12: 70562 (1)

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.2 Work with ASP.NET intrinsic objects.

References:

1. HttpRequest.Form Property

Click here for further information

MSDN, Microsoft

2. HttpRequest.Params Property

Click here for further information

MSDN, Microsoft

3. ASP.NET Intrinsic Objects

Click here for further information

MSDN, Microsoft

Question 6 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. An Extensible Markup Language (XML) Web service is defined as follows:

[WebService] public class PhoneService : WebService { [WebMethod] public string[] GetAvailableNumbers()

Page 13: 70562 (1)

{ // Omitted for brevity } }

You use Microsoft Visual Studio 2008 to add a Web reference named TelephoneServices to the application's project.

You need to call the GetAvailableNumbers Web method from a page.

Which code segment should you use?

WebService baseService = new WebService();TelephoneServices.PhoneService service = baseService.GetService(typeof(TelephoneServices.PhoneService));string[] numbers = service.GetAvailableNumbers();

TelephoneServices.PhoneService service = new TelephoneServices.PhoneService();string[] numbers = service.GetAvailableNumbers();

ChannelFactory<PhoneService> factory = new ChannelFactory<PhoneService>();PhoneService service = factory.CreateChannel();string[] numbers = service.GetAvailableNumbers();

ChannelFactory<WebService> factory = new ChannelFactory<WebService>();PhoneService service = (PhoneService)factory.CreateChannel();string[] numbers = service.GetAvailableNumbers();

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-020 Jump to Question ID

Question 6 Explanation:

You should create an instance of the TelephoneServices.PhoneService proxy class and

call its GetAvailableNumbers method. When you use Visual Studio to add a Web

reference to a Web service, Visual Studio generates a proxy class that contains the

same methods as the Web service. Calls made to the proxy methods are marshaled and

sent to the corresponding Web methods.

You should not use the ChannelFactory generic type to create a channel from the

PhoneService proxy class. The type of channel you create must implement

IOutputChannel or IRequestChannel. Web service proxy classes generated by Visual

Studio do not implement either of these interfaces.

Page 14: 70562 (1)

You should not call the GetService method of the WebService class to create a

PhoneService proxy instance. You must create the proxy instance by calling the

PhoneService proxy class constructor.

You should not use the ChannelFactory generic type to create a channel from the

WebService class. The type of channel you create must implement IOutputChannel or

IRequestChannel. The WebService class does not implement either of these interfaces.

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.3 Call a Windows Communication Foundation (WCF) service or a Web service from an

ASP.NET Web page.

References:

1. How to: Access a Web Service in Managed Code

Click here for further information

MSDN, Microsoft

2. How to: Add a Web Service to an Existing Web Project in Managed Code

Click here for further information

MSDN, Microsoft

3. How to: Call a Web Service

Click here for further information

MSDN, Microsoft

Page 15: 70562 (1)

Question 7 / 75 Mark for Review

You create a Web site by using Microsoft ASP.NET 3.5. The following code exists in the App_Code folder:

public class ObjectParameter : Parameter { public string ObjectTypeName {get; set; } public string PropertyName {get; set; }

protected override object Evaluate(HttpContext context, Control control) { if (String.IsNullOrEmpty(ObjectTypeName)) { throw new InvalidOperationException("ObjectTypeName is not set"); }

if (String.IsNullOrEmpty(PropertyName)) { throw new InvalidOperationException("PropertyName is not set"); }

Type type = System.Type.GetType(ObjectTypeName); BindingFlags flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.GetProperty; object value = type.InvokeMember(flags, null, null, null); return value; } }

public static class Security { public static string UserID { get { return Session["UserID"]; } } }

The following stored procedure exists in a Microsoft SQL Server 2008 database:

CREATE PROCEDURE GetStoresByUser @UserID INT AS SELECT StoreID, StoreName FROM Store where UserID=@UserID

The connection string to the database is stored in the connectionStrings section and has the name SupplyChain.

You need to use a data source control to call this stored procedure and pass the Security.UserID value to it as a parameter.

Page 16: 70562 (1)

Which declaration should you use?

<SqlDataSource ID="_dataSource" runat="server"ConnectionString="<%$ ConnectionStrings:SupplyChain%>"SelectCommand="GetStoresByUser"SelectCommandType="Text"><SelectParameters><cust:ObjectParameter Name="Security.UserID"/></SqlDataSource>

<ObjectDataSource ID="_dataSource" runat="server"DataObjectTypeName="<%$ ConnectionStrings:SupplyChain%>"TypeName="StoredProcedure"SelectMethod="GetStoresByUser"><SelectParameters><cust:ObjectParameter Name="UserID" ObjectTypeName="Security" PropertyName="UserID"/></SelectParameters></ObjectDataSource>

<SqlDataSource ID="_dataSource" runat="server"ConnectionString="<%$ ConnectionStrings:SupplyChain%>"SelectCommand="GetStoresByUser"SelectCommandType="StoredProcedure"><SelectParameters><cust:ObjectParameter Name="UserID" ObjectTypeName="Security" PropertyName="UserID"/></SelectParameters></SqlDataSource>

<ObjectDataSource ID="_dataSource" runat="server"DataObjectTypeName="StoredProcedure"TypeName="ConnectionStrings.SupplyChain"SelectMethod="GetStoresByUser"><SelectParameters><cust:ObjectParameter Name="Security.UserID"/></SelectParameters></ObjectDataSource>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-016 Jump to Question ID

Question 7 Explanation:

Page 17: 70562 (1)

You should use the following declaration:

<SqlDataSource ID="_dataSource" runat="server"

ConnectionString="<%$ ConnectionStrings:SupplyChain%>"

SelectCommand="GetStoresByUser"

SelectCommandType="StoredProcedure">

<SelectParameters>

<cust:ObjectParameter

Name="UserID"

ObjectTypeName="Security"

PropertyName="UserID"/>

</SelectParameters>

</SqlDataSource>

This declares a SqlDataSource control that connects to the database. The

SelectCommand property specifies the SQL command or stored procedure to execute.

In this scenario, the SelectCommandType property is set to StoredProcedure, so the

value specified in the SelectCommand property is a stored procedure. The

SelectParameters property defines the parameters to pass to the stored procedure. In

this scenario, the stored procedure accepts a single String parameter. To pass the value

of Security.UserID as a parameter, you should use the ObjectParameter class and set its

properties appropriately. The ObjectTypeName property specifies the name of the class,

and the PropertyName property specifies the property of that class. In this scenario, the

name of the class is Security, and the name of the property of that class is UserID.

You should not use the ObjectDataSource control. This control allows you to bind to

business or data objects. The TypeName property of this control should specify the

common language runtime (CLR) type of the object to query. The SelectMethod

property should specify a method of that type that is used to query data. The

DataObjectTypeName property should specify a CLR type that can be used for a

parameter in an insert, update, or delete operation.

You should not use the following declaration:

<SqlDataSource ID="_dataSource" runat="server"

ConnectionString="<%$ ConnectionStrings:SupplyChain%>"

SelectCommand="GetStoresByUser"

SelectCommandType="Text">

<SelectParameters>

<cust:ObjectParameter Name="Security.UserID"/>

</SqlDataSource>

This code sets the SelectCommandType property to Text, which indicates that the

Page 18: 70562 (1)

SelectCommand property value is a SQL statement. Also, the ObjectParameter property

does not set the ObjectTypeName and PropertyName properties, but instead sets the

Name property to Security.UserID. You must set the Name property to the name of a

parameter expected by the stored procedure. Also, in this scenario, if you do not set the

ObjectTypeName and PropertyName properties, the ObjectParameter class throws an

exception.

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.4 Implement a DataSource control.

References:

1. Parameter Class

Click here for further information

MSDN, Microsoft

2. Using Parameters with the SqlDataSource Control

Click here for further information

MSDN, Microsoft

Question 8 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The application is hosted on a Web farm, and it uses in-process session state. It is not guaranteed that a user will remain connected to the same Web server across multiple requests.

Page 19: 70562 (1)

A Web page contains the following code (line numbers are included for reference only):

01 protected void Page_Load(object sender, EventArgs e) 02 { 03 String connStr = WebConfigurationManager.ConnectionStrings[0].ConnectionString; 04 using (SqlConnection conn = new SqlConnection(connStr)) 05 { 06 SqlCommand cmd = new SqlCommand("GetExams", conn); 07 SqlDataAdapter adapter = new SqlDataAdapter(cmd); 08 DataSet ds = new DataSet(); 09 adapter.Fill(ds); 10 11 if (Request.QueryString["Process"] == Boolean.TrueString) 12 { 13 14 } 15 } 16 }

This code fills a DataSet instance with exam information from a Microsoft SQL Server database. If a query string parameter named Process has the value True, you need to have a page named ExamProcesser.aspx access the data in the DataSet instance.

You need to add code at line 13 to accomplish your goal.

Which code segment should you use?

Session["ExamInfo"] = ds;HttpWebRequest.Create("ExamProcesser.aspx").GetResponse();

Context.Items.Add("ExamInfo", ds);Response.Redirect("ExamProcesser.aspx");

Session["ExamInfo"] = ds;Response.RedirectLocation = "ExamProcesser.aspx";

Context.Items.Add("ExamInfo", ds);Server.Transfer("ExamProcesser.aspx");

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-002 Jump to Question ID

Question 8 Explanation:

Page 20: 70562 (1)

You should store the DataSet instance in the current HttpContext instance and call the

Transfer method of the HttpServerUtility class. The Transfer method transfers the

current request to another page or HTTP handler without having the browser perform a

redirect. An HttpContext instance gets created with each request to the application.

This means that any data currently stored in the current HttpContext instance will be

available after the transfer.

You should not call the Redirect method of the HttpResponse class. This method sends

an HTTP response to the browser that instructs the browser to request the specified

page. Because the application is hosted on a Web farm, a user might be redirected to

another server with the request. If this happens, the DataSet instance stored in the

current HttpContext instance will get removed.

You should not store the DataSet instance in the user's HttpSessionState instance and

call the GetResponse method of an HttpWebRequest instance. The GetResponse method

of the HttpWebRequest instance sends an HTTP request to a Web server. In this

scenario, the Web server to which the user is currently connected will initiate the

request. This means the session associated with that request will be different from the

one associated with the user.

You should not store the DataSet instance in the user's HttpSessionState instance and

set the RedirectLocation property of the HttpResponse class. The RedirectLocation

property instructs the browser to request the page indicated by the specified URL. The

application uses in-process session state, which means that a user's session is not

shared across multiple Web servers. Because the application is hosted on a Web farm, a

user might be redirected to another server.

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.6 Handle events and control page flow.

References:

1. Server.Transfer Method

Page 21: 70562 (1)

Click here for further information

MSDN, Microsoft

2. How to: Redirect Users to Another Page

Click here for further information

MSDN, Microsoft

Question 9 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You create a page named GenericError.aspx that displays a message to the user when an unhandled exception occurs. Most users access the application at http://www.bcdtrain.com/Crm. If the user accesses the application at http://127.0.0.1/Crm, the application must display an automatically generated page containing the stack trace when an unhandled exception occurs.

You need to configure the Web.config file accordingly.

Which configuration should you use?

<customErrors mode="Off"><error statusCode="500" redirect="GenericError.aspx"></customErrors>

<customErrors mode="RemoteOnly" defaultRedirect="GenericError.aspx"></customErrors>

<customErrors mode="On"><error statusCode="500" redirect="GenericError.aspx"></customErrors>

<customErrors mode="Off" defaultRedirect="GenericError.aspx"></customErrors>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application

Page 22: 70562 (1)

Development (C#) (Preview) Question ID: jehMS_70-562CS-043 Jump to Question ID

Question 9 Explanation:

You should configure the customErrors element to indicate how the application displays

unhandled exceptions. You should set the defaultRedirect attribute to GenericError.aspx.

This attribute specifies the default URL to which the application will redirect when an

unhandled exception occurs. You should set the mode attribute to RemoteOnly. This

attribute specifies that only unhandled exceptions from remote users will cause the

application to redirect to GenericError.aspx. In the context of custom errors, local users

are those who access the application at http://127.0.0.1/Crm. All other users are

considered remote users. When the mode attribute is set to RemoteOnly, local users

see an automatically generated page containing the stack trace when unhandled

exceptions occur.

You should not set the mode attribute to On. This specifies that the application should

never display the automatically generated page containing the stack trace when

unhandled exceptions occur.

You should not set the mode attribute to Off. This specifies that the application should

always display the automatically generated page containing the stack trace when

unhandled exceptions occur.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.1 Configure debugging and custom errors.

References:

1. customErrors Element (ASP.NET Settings Schema)

Click here for further information

MSDN, Microsoft

Page 23: 70562 (1)

2. Rich Custom Error Handling with ASP.NET

Click here for further information

MSDN, Microsoft

Question 10 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You add a the following code to a generic handler file named ValidationHandler.ashx (line numbers are included for reference only):

01 public class ValidationHandler : IHttpHandler 02 { 03 public void ProcessRequest(HttpContext context) 04 { 05 Bitmap validationBitmap = (Bitmap)Session["ValidationImage"]; 06 07 } 08 public bool IsReusable 09 { 10 get 11 { 12 return false; 13 } 14 } 15 }

You need to render the validationBitmap instance as a JPEG image when the ValidationHandler.ashx is requested.

Which code segment should you add at line 06?

context.Response.ContentType = "image/jpeg";context.Response.Write(validationBitmap);

context.Response.ContentType = "image/jpeg";validationBitmap.Save(context.Request.InputStream, ImageFormat.Jpeg);

context.Response.ContentType = "image/jpeg";context.Response.Write(validationBitmap.RawFormat);

context.Response.ContentType = "image/jpeg";

Page 24: 70562 (1)

validationBitmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-001 Jump to Question ID

Question 10 Explanation:

You should set the Response.ContentType property of the context instance to

image/jpeg, and you should call the Save method of the validationBitmap instance. The

ContentType property specifies the type of content that is rendered by the generic

handler. By setting the value of the property to image/jpeg, you specify that a JPEG

image is rendered. The Save method of the Bitmap class allows you to save an image to

a file or Stream instance. The Response.OutputStream property of the HttpContext

class represents the output stream of the HTTP response. You should use this stream to

render the image to the browser. You can accomplish this by passing the

context.Response.OutputStream instance as the first parameter to the Save method.

The second parameter of the Save method specifies the format in which to save the

image.

You should not pass the context.Request.InputStream instance as the first parameter to

the Save method. This instance represents the input stream of the HTTP request.

You should not pass the validationBitmap instance as the parameter to the Write

method of the context.Response instance. This would call the ToString method of the

validationBitmap instance, which does not render the image to the browser.

You should not pass the validationBitmap.RawFormat instance as the parameter to the

Write method of the context.Response instance. This would call the ToString method of

the validationBitmap.ImageFormat instance, which does not render the image to the

browser.

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Page 25: 70562 (1)

Sub-Objective:

7.7 Implement the Generic Handler.

References:

1. Introduction to HTTP Handlers

Click here for further information

MSDN, Microsoft

2. ASP.NET: Create Snazzy Web Charts and Graphics on the Fly with the .NET Framework

Click here for further information

MSDN, Microsoft

Question 11 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The application uses diagnostic tracing to log unhandled exceptions. A page contains the following markup:

<asp:ScriptManager ID="_scriptManager" runat="server"/> <asp:UpdatePanel ID="_udpatePanel" runat="server"> <asp:Button ID="_button" runat="server" Text="Process"/> </asp:UpdatePanel>

When you click the Button control an unhandled exception occurs. However, the exception does not get logged.

You need to configure the application so that the unhandled exception produced by clicking the Button control gets logged.

What should you do?

Handle the Error event of the Page class. Call the Write method of the System.Diagnostics.Trace class to log the exception.

Handle the pageLoaded event of the PageRequestManager client object. Call the trace function of the Sys.Debug client object to log the exception.

Page 26: 70562 (1)

Handle the endRequest event of the PageRequestManager client object. Call the trace function of the Sys.Debug client object to log the exception.

Handle the AsyncPostBackError event of the ScriptManager control. Call the Write method of the System.Diagnostics.Trace class to log the exception.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-047 Jump to Question ID

Question 11 Explanation:

You should handle the AsyncPostBackError event of the ScriptManager control and call

the Write method of the System.Diagnostics.Trace class to log the exception. The

AsyncPostBackError event is raised whenever an unhandled exception occurs during an

asynchronous post back. Because the Button control is a child of the UpdatePanel

control, the Button control performs an asynchronous post back by default when it is

clicked. The System.Diagnostics.Trace class allows you to write diagnostic trace

messages.

You should not handle the Error event of the Page class. This event is raised when

unhandled exceptions occur during synchronous post backs, not asynchronous post

backs.

You should not handle the endRequest event of the PageRequestManager client object

and call the trace function of the Sys.Debug client object. The endRequest event is

raised on the client when an asynchronous request ends. The Sys.Debug.trace function

writes messages to a TextArea element that has an ID of TraceConsole. It does not

implement diagnostic tracing.

You should not handle the pageLoaded event of the PageRequestManager client object

and call the trace function of the Sys.Debug client object. The pageLoaded event is

raised on the client after an asynchronous request ends and UpdatePanel control

regions are updated. The Sys.Debug.trace function writes messages to a TextArea

element that has an ID of TraceConsole. It does not implement diagnostic tracing.

Page 27: 70562 (1)

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.3 Debug unhandled exceptions when using ASP.NET AJAX.

References:

1. Debugging and Tracing AJAX Applications Overview

Click here for further information

MSDN, Microsoft

2. ScriptManager.AsyncPostBackErrorMessage Property

Click here for further information

MSDN, Microsoft

3. Customizing Error Handling for ASP.NET UpdatePanel Controls

Click here for further information

MSDN, Microsoft

4. ScriptManager Control Overview

Click here for further information

MSDN, Microsoft

5. Trace Class

Click here for further information

MSDN, Microsoft

Page 28: 70562 (1)

Question 12 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following Asynchronous JavaScript and XML (AJAX)-enabled Windows Communication Foundation (WFC) service exists in an ASP.NET Web application:

namespace BcdTrain.Information.Services { [ServiceContract(Namespace="BcdTrain.Services")] public class SearchService { [OperationContract] public string LookupPhoneNumber(string phoneNumber) { // Code omitted for brevity } } }

You add the ScriptManager control to a page and reference the service. You also add a TextBox control named _phoneNumberTextBox. You need to call the LookupPhoneNumber method, passing to it the text displayed in the TextBox control. You must also display the return value of the method in a browser alert window. The naming container of the TextBox control is the page.

You need to write the appropriate JavaScript code to call the LookupPhoneNumber method.

Which code segment should you use?

var phoneNumber = $get("_phoneNumberTextBox").value;BcdTrain.Information.Services.SearchService.LookupPhoneNumber(phoneNumber);window.alert($get("ReturnValue").value);

var phoneNumber = $get("_phoneNumberTextBox").value;var result = BcdTrain. Services.SearchService.LookupPhoneNumber(phoneNumber);window.alert(result);

var phoneNumber = $get("_phoneNumberTextBox").value;BcdTrain.Services.SearchService.LookupPhoneNumber(phoneNumber, OnSuccess);

function OnSuccess(){window.alert($get("ReturnValue").value);}

Page 29: 70562 (1)

var phoneNumber = $get("_phoneNumberTextBox").value;BcdTrain.Services.SearchService.LookupPhoneNumber(phoneNumber, OnSuccess);

function OnSuccess(result){window.alert(result);}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-015 Jump to Question ID

Question 12 Explanation:

You should use the following JavaScript code segment:

var phoneNumber = $get("_phoneNumberTextBox").value;

BcdTrain.Services.SearchService.LookupPhoneNumber(phoneNumber, OnSuccess);

function OnSuccess(result)

{

window.alert(result);

}

The first line of code retrieves the value of the TextBox control, which will be passed to

the LookupPhoneNumber method of SearchService. The second line of code makes a

call to the method. When calling AJAX-enabled Web services from JavaScript, you must

specify the service contract's XML namespace as the JavaScript namespace. The reason

is because ASP.NET AJAX creates a JavaScript Object Notation (JSON) class that is part

of a namespace that uses the same name as the service contract's XML namespace.

Because the default XML namespace is always http://tempura.org, this allows ASP.NET

AJAX to register a namespace even if a service contract is not part of a .NET

namespace. The first parameters to the JSON function match the first parameters to the

.NET method. In addition, the JSON function accepts another parameter that specifies

another JavaScript function to call after the service method returns. This function

accepts a single parameter that specifies the return value of the service method call.

You should not use the following JavaScript code segment:

var phoneNumber = $get("_phoneNumberTextBox").value;

BcdTrain.Information.Services.SearchService.LookupPhoneNumber(phoneNumber);

Page 30: 70562 (1)

window.alert($get("ReturnValue").value);

This code uses the .NET namespace instead of the service contract's namespace, which

was used to register the JSON namespace. Also, this code does not specify a second

parameter to identify the JavaScript function to call after the service method returns.

You should not use $get to access the return value. The $get function retrieves

Document Object Model (DOM) elements in a browser-independent way.

You should not use the following JavaScript code segment:

var phoneNumber = $get("_phoneNumberTextBox").value;

BcdTrain.Services.SearchService.LookupPhoneNumber(phoneNumber, OnSuccess);

function OnSuccess()

{

window.alert($get("ReturnValue").value);

}

This code does not declare the OnSuccess function correctly. The function must accept a

single parameter that specifies the return value of the service method call. The $get

function retrieves DOM elements in a browser-independent way.

You should not use the following JavaScript code segment:

var phoneNumber = $get("_phoneNumberTextBox").value;

var result = BcdTrain. Services.SearchService.LookupPhoneNumber(phoneNumber);

window.alert(result);

The LookupPhoneNumber JSON function does not return a value. You must specify

another JavaScript function to retrieve the return value of the service method call.

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

Page 31: 70562 (1)

5.3 Consume services from client scripts.

References:

1. Exposing WCF Services to Client Script

Click here for further information

MSDN, Microsoft

2. Calling Web Services from Client Script

Click here for further information

MSDN, Microsoft

3. An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET

Click here for further information

MSDN, Microsoft

Question 13 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You create a base user control named AssignmentUserControl. Ten user controls derive from AssignmentUserControl. You add a PlaceHolder control named _placeHolder to a page. You create the following method to load one of the 10 user controls into _placeHolder:

private void DisplayAssignmentUserControl(string userControlPath) { }

The path of the user control to load is passed as a parameter to the method.

You need to write code to load the user control. Your solution must support new AssignmentUserControl-derived user controls without the need to re-implement the method.

Which code segment should you use?

Page 32: 70562 (1)

AssignmentUserControl control = new AssignmentUserControl();LoadControl(userControlPath);_placeHolder.Controls.Add(control);

AssignmentUserControl control = new AssignmentUserControl();control.ID = userControlPath;_placeHolder.Controls.Add(control);

Control control _placeHolder.FindControl(userControlPath);_placeHolder.Controls.Add(control);

Control control = LoadControl(userControlPath);_placeHolder.Controls.Add(control);

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-009 Jump to Question ID

Question 13 Explanation:

You should call the LoadControl method of the Page class to load the user control, and

then call the Add method of the _placeHolder instance's Controls collection. The

LoadControl method loads a user control from a file and returns a Control instance that

represents the loaded user control. The Add method of the _placeHolder instance's

Controls collection adds the user control to the _placeHolder instance.

You should not create an instance of AssignmentUserControl and add it to the

_placeHolder instance's Controls collection. To load a user control, you must call the

LoadControl method of the Page class and specify the path to the user control as a

parameter.

You should not call the FindControl method of the _placeHolder instance to load a user

control. The FindControl method returns instances of controls that are already added to

a control's hierarchy.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Page 33: 70562 (1)

Sub-Objective:

2.2 Load user controls dynamically.

References:

1. How to: Create Instances of ASP.NET User Controls Programmatically

Click here for further information

MSDN, Microsoft

Question 14 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following markup exists on a page:

<asp:ScriptManager ID="_scriptManager" runat="server"/> <asp:UpdatePanel ID="_updatePanel" runat="server"> <ContentTemplate> <asp:GridView ID="_gridView" runat="server"/> <asp:Button ID="_submitButton" runat="server" Text="Submit"/> <asp:Button ID="_refreshButton" runat="server" Text="Refresh"/> </ContentTemplate> </asp:UpdatePanel>

You need to write code so that the _refreshButton control causes the entire page to be posted back.

Which code segment should you use?

protected void Page_Load(object sender, EventArgs e){Page.RegisterRequiresRaiseEvent(_refreshButton);}

protected void Page_Load(object sender, EventArgs e){Page.RegisterRequiresPostBack(_refreshButton);}

protected void Page_Load(object sender, EventArgs e){

Page 34: 70562 (1)

_scriptManager.RegisterPostBackControl(_refreshButton);}

protected void Page_Load(object sender, EventArgs e){ _scriptManager.RegisterAsyncPostBackControl(_refreshButton);}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-018 Jump to Question ID

Question 14 Explanation:

You should call the RegisterPostBackControl method of the ScriptManager class. This

method instructs a control to always cause a full post back instead of an asynchronous

post back. By default, controls that are children of an UpdatePanel control perform

asynchronous post backs if the ChildrenAsTriggers property of the UpdatePanel control

is set to true, which is the default value. To prevent a child control from performing an

asynchronous post back, you must either set ChildrenAsTriggers to false or call the

RegisterPostBackControl method for the child control.

You should not call the RegisterAsynchronousPostBackControl method of the

ScriptManager class. This method instructs a control to always perform an

asynchronous post back.

You should not call the RegisterRequiresPostBack method of the Page class. This

method instructs the page processor to call methods of the IPostBackDataHandler

interface implemented by a control when a page post back occurs. It does not matter

whether the post back is a full post back or an asynchronous post back.

You should not call the RegisterRequiresRaiseEvent method of the Page class. This

method instructs the page processor to call the RaisePostBackEvent method of the

IPostBackEventHandler interface implemented by a control when a page post back

occurs. It does not matter whether the post back is a full post back or an asynchronous

post back.

Page 35: 70562 (1)

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.1 Implement Web Forms by using ASP.NET AJAX.

References:

1. ScriptManager Enables AJAX In Your Web Apps

Click here for further information

MSDN, Microsoft

2. ScriptManager.RegisterPostBackControl Method

Click here for further information

MSDN, Microsoft

3. ScriptManager.RegisterAsyncPostBackControl Method

Click here for further information

MSDN, Microsoft

Question 15 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. A page in the application allows users to dynamically configure its layout. By clicking a Button control on the page, users can dynamically add user controls to the page. The following code exists for the page:

public partial class PortalPage : System.Web.UI.Page

Page 36: 70562 (1)

{ private int _sectionCount = 0;

protected void AddButton_Click(object sender, EventArgs e) { Control control = this.Load("Section.ascx"); Controls.Add(control); _sectionCount++; } }

You need to ensure that the page retains the dynamically-added user controls as it undergoes post-back requests. Your solution must not allow a configuration change to override this functionality.

Which code segments should you use? (Each correct answer presents part of the solution. Choose three.)

protected override LoadViewState(object savedState){_sectionCount = (int)savedState;}

protected override object SaveViewState(){ViewState["SectionCount"] = _sectionCount;}

protected override void LoadControlState(object savedState){Pair pair = (Pair)savedState;base.LoadControlState(pair.First);_sectionCount = (int)pair.Second;for (int index = 0; index < _sectionCount; index++){Control control = this.LoadControl("Section.ascx");Controls.Add(control);}}

protected override object SaveControlState(){Pair pair = new Pair();pair.First = base.SaveControlState();pair.Second = _sectionCount;return pair;}

protected override void OnInit(EventArgs e){Page.RegisterRequiresControlState(this);base.OnInit(e);}

Page 37: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-003 Jump to Question ID

Question 15 Explanation:

You should use control state to persist the count of the dynamically-added user

controls. A developer or administrator cannot disable control state for a page through a

configuration change. You should override SaveControlState to save the current count

of dynamically-added user controls. However, you must also save the default control

state of the page. To do this, you should create a Pair instance, which simply allows you

to group two objects together. You should then return the Pair instance from the

method. The instance that you return is passed to the LoadControlState method when

the page loads. This allows you to determine the number of user controls that were

dynamically added during the last page request and recreate those controls. To enable

control state, you must call the RegisterRequiresControlState method of the Page class.

You should call this method from within the OnInit method of the Page class.

You should not override LoadViewState and SaveViewState. These methods give you

greater control over what is stored and retrieved from view state. However, a developer

or administrator can disable view state for the page after the application is deployed

through a configuration change.

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.5 Implement session state, view state, control state, cookies, cache, or application

state.

References:

1. Control State vs. View State Example

Click here for further information

MSDN, Microsoft

Page 38: 70562 (1)

2. ASP.NET State Management Overview

Click here for further information

MSDN, Microsoft

3. Page.RequiresControlState Method

Click here for further information

MSDN, Microsoft

Question 16 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You create a custom server control named Circle, which exists in the BcdTrain.WebControls namespace. The control contains a single read-write property named Radius of type Double. You implement the control as an Asynchronous JavaScript and XML (AJAX) extender control that allows the Radius property to be set in client script. You implement the following code in an associated JavaScript file (line numbers are included for reference only):

01 Type.registerNamespace("BcdTrain.WebControls"); 02 BcdTrain.WebControls.Circle = function(elem) 03 { 04 BcdTrain.WebControls.Circle.initializeBase(this, elem); 05 this._radius = 0; 06 } 07 BcdTrain.WebControls.Circle.prototype = 08 { 09 initialize : function() 10 { 11 BcdTrain.WebControls.callBaseMethod(this, 'initialize'); 12 }, 13 dispose : function() 14 { 15 BcdTrain.WebControls.callBaseMethod(this, 'dispose'); 16 }, 17 18 } 19 BcdTrain.WebControls.Circle.registerClass('BcdTrain.WebControls.Circle', Sys.UI.Control);

You need to define the Radius property in the JavaScript file:

Which code segment should you insert at line 17?

Page 39: 70562 (1)

Radius : function(){return this._radius;}

get_Radius : function(){return this._radius;},set_Radius : function(value){this._radius = value;}

Radius : function(){return this._radius;},Radius : function(value){this._radius = value;}

Radius : function(value){this._radius = value;}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-067 Jump to Question ID

Question 16 Explanation:

You should use the following code segment:

get_Radius : function()

{

return this._radius;

},

set_Radius : function(value)

{

this._radius = value;

}

This code defines two functions named get_Radius and set_Radius. Because JavaScript

does not support the concept of properties, you must implement the Radius property as

Page 40: 70562 (1)

two distinct functions with different names. The get_Radius function returns the value

of the Radius property. The set_Radius function sets the value of the Radius property.

You should not use the following code segment:

Radius : function()

{

return this._radius;

},

Radius : function(value)

{

this._radius = value;

}

This code defines two functions with the same name. Because JavaScript does not

support the concept of properties, you must implement the Radius property as two

distinct functions with different names.

You should not use the following code segment:

Radius : function()

{

return this._radius;

}

This code defines a single function that returns the value of the Radius property.

However, you should also define a function that sets the value of the Radius property.

You should not use the following code segment:

Radius : function(value)

{

this._radius = value;

}

This code defines a single function that sets the value of the Radius property. However,

you should also define a function that returns the value of the Radius property.

Page 41: 70562 (1)

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.2 Interact with the ASP.NET AJAX client-side library.

References:

1. Adding ASP.NET AJAX Client Capabilities to a Web Server Control

Click here for further information

MSDN, Microsoft

2. ScriptManager Enables AJAX In Your Web Apps

Click here for further information

MSDN, Microsoft

3. An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET

Click here for further information

MSDN, Microsoft

4. Creating Custom Client Script by Using the Microsoft AJAX Library

Click here for further information

MSDN, Microsoft

Question 17 / 75 Mark for Review

Page 42: 70562 (1)

You create a Web application by using Microsoft ASP.NET 3.5. You need to build the application and deploy it to a remote server. You use virtual private networking (VPN) to connect to the remote server's network. You are granted access to the folder where you need to deploy the application. Front Page Server Extensions are not installed on the remote server.

You need to use Microsoft Visual Studio 2008 to deploy the application. Your solution must prevent access to source code files used by the application.

What should you do?

Use the Copy Web Site tool and choose the File System option.

Use the Publish Web Site tool and choose the Remote Site option.

Use the Publish Web Site tool and choose the File System option.

Use the Copy Web Site tool and choose the Remote Site option.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-056 Jump to Question ID

Question 17 Explanation:

You should use the Publish Web Site tool and choose the File System option. This allows

you to compile and deploy the application to a local directory, network drive, or file

share.

You should not use the Publish Web Site tool and choose the Remote Site option. This

option requires that the server have Front Page Server Extensions installed.

You should not choose the Copy Web Site tool. This tool copies project files, which

includes source code, to a target location.

Objective:

List all questions for this objective</P< td>

Configuring and Deploying Web

Page 43: 70562 (1)

Applications

Sub-Objective:

1.5 Publish Web applications.

References:

1. Walkthrough: Publishing a Web Site

Click here for further information

MSDN, Microsoft

2. Publish Web Site Dialog Box

Click here for further information

MSDN, Microsoft

3. How to: Publish Web Sites (Visual Studio)

Click here for further information

MSDN, Microsoft

Question 18 / 75 Mark for Review

You create a Web site by using Microsoft ASP.NET 3.5. The following code exists in the App_Code folder:

namespace BcdTrain.Providers { public class SessionSiteMapProvider : SiteMapProvider { // Members omitted for brevity } }

You need to modify the Web.config file to ensure that SiteMapDataSource controls use the SessionSiteMapProvider class by default.

Which configuration should you use?

Page 44: 70562 (1)

<siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider"></siteMap>

<siteMap defaultProvider="SessionSiteMapProvider"><providers><add name="BcdTrain.Providers.SessionSiteMapProvider" type="SiteMapProvider"</providers></siteMap>

<siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider, App_Code"></siteMap>

<siteMap defaultProvider="SessionSiteMapProvider"><providers><add name="SessionSiteMapProvider" type="BcdTrain.Providers.SessionSiteMapProvider, App_Code"</providers></siteMap>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-034 Jump to Question ID

Question 18 Explanation:

You should use the following configuration:

<siteMap defaultProvider="SessionSiteMapProvider">

<providers>

<add

name="SessionSiteMapProvider"

type="BcdTrain.Providers.SessionSiteMapProvider, App_Code"

</providers>

</siteMap>

This configuration adds a site map provider named SessionSiteMapProvider that maps

to the SessionSiteMapProvider class in the BcdTrain.Providers namespace. The name

attribute specifies a user-friendly name of the provider. The type attribute specifies the

fully-qualified type name of the provider in the form [Namespace].[Class], [Assembly].

App_Code indicates that the assembly is one that is generated for code in the

App_Code folder. This configuration also sets the defaultProvider attribute to

Page 45: 70562 (1)

SessionSiteMapProvider, which is the name of the provider that is added.

SiteMapDataSource controls that do not specify a value for the SiteMapProvider

property will automatically use the default provider.

You should not use the following configuration:

<siteMap defaultProvider="SessionSiteMapProvider">

<providers>

<add

name="BcdTrain.Providers.SessionSiteMapProvider"

type="SiteMapProvider"

</providers>

</siteMap>

The defaultProvider attribute must match the name of a defined site map provider. Also,

the type attribute must specify the fully-qualified type name of a site map provider.

You should not use the following configuration:

<siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider">

</siteMap>

The defaultProvider attribute must match the name of a defined site map provider. In

this configuration, no additional site map providers are defined.

You should not use the following configuration:

<siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider, App_Code">

</siteMap>

The defaultProvider attribute must match the name of a defined site map provider. In

this configuration, no additional site map providers are defined.

Objective:

List all questions for this objective</P< td>

Configuring and Deploying Web

Applications

Page 46: 70562 (1)

Sub-Objective:

1.1 Configure providers.

References:

1. Implementing ASP.NET Site-Map Providers

Click here for further information

MSDN, Microsoft

2. How to: Configure Multiple Site Maps and Site-Map Providers

Click here for further information

MSDN, Microsoft

3. ASP.NET Site Maps

Click here for further information

MSDN, Microsoft

Question 19 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following code exists in the application:

public class Account { public double Balance { get; set; }

public void Deposit(double amount) { Balance += amount; }

public void Withdraw(double amount) { System.Diagnostics.Trace.WriteLineIf(amount > Balance, "Potential Overdraft."); if (amount <= Balance) { Balance -= amount; }

Page 47: 70562 (1)

} }

This code writes a trace message if there is potential for an overdraft.

You need to configure the Web.config file to write the trace message to the trace viewer tool (Trace.axd).

Which configurations should you use? (Each correct answer presents part of the solution. Choose two.)

<trace enabled="true"/>

<system.diagnostics><trace><listeners><add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/></listeners></trace></system.diagnostics>

<trace enabled="false" writeToDiagnosticsTrace="true"/>

<trace enabled="false" writeToDiagnosticsTrace="true" pageOutput="false"/>

<system.diagnostics><switches><add name="PageOutput" value="Trace.axd"/></switches></system.diagnostics>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-040 Jump to Question ID

Question 19 Explanation:

You should use the following configuration:

<system.diagnostics>

<trace>

<listeners>

<add name="WebPageTraceListener"

Page 48: 70562 (1)

type="System.Web.WebPageTraceListener,

System.Web,

Version=2.0.3600.0,

Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"/>

</listeners>

</trace>

</system.diagnostics>

This adds a new trace listener to the Listeners collection of the

System.Diagnostics.Trace class. The WebPageTraceListener class is implemented to

write diagnostic trace messages to the ASP.NET tracing subsystem. Whenever you write

a trace message by using the System.Diagnostics.Trace class, that message is also

written to the ASP.NET tracing subsystem. You can view messages written to the

ASP.NET tracing subsystem by accessing Trace.axd in the current Web application.

You should also use the following configuration:

<trace enabled="true"/>

This configuration enables ASP.NET tracing. If you do not enable ASP.NET tracing,

nothing will be written to the ASP.NET tracing subsystem. Note that you must add this

configuration in the <system.web> section.

You should not use the following configuration:

<trace enabled="false" writeToDiagnosticsTrace="true"/>

This configuration disables ASP.NET tracing. The writeToDiagnosticsTrace attribute

specifies whether ASP.NET trace messages should be written to listeners defined for

diagnostic tracing. However, in this scenario, you need to write diagnostic trace

messages to the ASP.NET tracing subsystem.

You should not use the following configuration:

<trace enabled="false" writeToDiagnosticsTrace="true" pageOutput="false"/>

This configuration disables ASP.NET tracing. The writeToDiagnosticsTrace attribute

specifies whether ASP.NET trace messages should be written to listeners defined for

diagnostic tracing. However, in this scenario, you need to write diagnostic trace

messages to the ASP.NET tracing subsystem. The pageOutput attribute specifies

whether ASP.NET trace messages can be viewed by requesting pages in addition to

Trace.axd.

Page 49: 70562 (1)

You should not use the following configuration:

<system.diagnostics>

<switches>

<add name="PageOutput" value="Trace.axd"/>

</switches>

</system.diagnostics>

This configuration defines a trace switch named PageOutput that is set to the value

Trace.axd. Trace switches allow you to write conditional diagnostic trace messages in an

application based on the value of the switch.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.4 Implement tracing of a Web application.

References:

1. Walkthrough: Integrating ASP.NET Tracing with System.Diagnostics Tracing

Click here for further information

MSDN, Microsoft

2. How to: View ASP.NET Trace Information with the Trace Viewer

Click here for further information

MSDN, Microsoft

3. How to: Enable Tracing for an ASP.NET Application

Click here for further information

MSDN, Microsoft

4. ASP.NET Tracing Overview

Page 50: 70562 (1)

Click here for further information

MSDN, Microsoft

Question 20 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. A page contains a DropDownList control named _cultureList. This control displays a list of languages to which the user interface can be localized. The page uses localized resources in the App_LocalResources folder.

You need to write code to localize the page based on the selected language. Your solution must retain the localized version of the page across post-back requests.

Which code segment should you use?

protected override void OnInit(EventArgs e){string culture = _cultureInfo.SelectedValue;Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);}

protected override void OnPreRender(EventArgs e){string culture = _cultureInfo.SelectedValue;Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);}

protected override void OnPreInit(EventArgs e){string culture = _cultureInfo.SelectedValue;Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);}

protected override void InitializeCulture(){string culture = Request.Form["_cultureList"];if (culture != null){Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);}}

Page 51: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-005 Jump to Question ID

Question 20 Explanation:

You should override the InitializeCulture method and set the CurrentUICulture property

of the current Thread instance. The CurrentUICulture property represents the user

interface culture. It specifies the culture that is used to read localized resources. A

DropDownList control saves its selected value in an HTML form field. Because of this,

you can easily determine the current culture by accessing the value of this field. This

allows you to reset the CurrentUICulture property to the current culture across post-

back requests.

You should not set the CurrentUICulture property in the OnInit method. This will

prevent the current culture from being retained across post-back requests.

You should not set the CurrentCulture property. The CurrentCulture property allows you

to specify a culture that is used to display and format numbers, currencies, dates and

times. It does not specify the culture that is used to read localized resources.

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.3 Implement globalization and accessibility.

References:

1. How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization

Click here for further information

MSDN, Microsoft

Page 52: 70562 (1)

Question 21 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. Your application must load employee data from an XML file into a DataSet instance. The XML file contains an inline schema.

You need to call a method of the DataSet class to load the data.

What should you do?

Call the ReadXml method with the ReadSchema XML read mode.

Call the ReadXml method with the InferTypedSchema XML read mode.

Call the ReadXmlSchema method.

Call the ReadXml method with the InferSchema XML read mode.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-062 Jump to Question ID

Question 21 Explanation:

You should call the ReadXml method with the ReadSchema XML read mode. This

method reads data and loads schema information from an inline schema.

You should not call the ReadXml method with the InferSchema XML read mode. This

method loads data and infers the schema from the data. It does not read an inline

schema.

You should not call the ReadXml method with the InferTypedSchema XML read mode.

This method loads data and infers a strongly-typed schema from the data. It does not

read an inline schema.

Page 53: 70562 (1)

You should not call the ReadXmlSchema method. This method reads schema

information from a schema file or stream. In this scenario, the XML file contains both

the schema and the data.

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.2 Manipulate data by using DataSet and DataReader objects.

References:

1. Loading a DataSet from XML

Click here for further information

MSDN, Microsoft

2. XmlReadMode Enumeration

Click here for further information

MSDN, Microsoft

3. DataSet.ReadXml Method (Stream, XmlReadMode)

Click here for further information

MSDN, Microsoft

Page 54: 70562 (1)

Question 22 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You are dynamically loading a user control into a container on a page.

You need to load the control during the correct page event so that the control participates in post back data processing and validation.

What should you do?

Handle the PreRender event and load the user control.

Handle the Init event and load the user control.

Handle the Load event and load the user control.

Handle the SaveStateComplete event and load the user control.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-041 Jump to Question ID

Question 22 Explanation:

You should handle the Init event and load the user control. This event is raised after a

control is initialized. For a dynamically added user control to participate in post back

data processing and validation, you must load the control during the Init event.

You should not handle the Load event and load the user control. This event is raised

after the Init event, indicating that a control is loaded. For a dynamically added user

control to participate in post back data processing and validation, you must load the

control during the Init event.

You should not handle the PreRender event and load the user control. This event is

raised just before the control is rendered. For a dynamically added user control to

Page 55: 70562 (1)

participate in post back data processing and validation, you must load the control

during the Init event.

You should not handle the SaveStateComplete event and load the user control. This

event is raised after the PreRender event and after the control's view state and control

state are saved. For a dynamically added user control to participate in post back data

processing and validation, you must load the control during the Init event.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.2 Load user controls dynamically.

References:

1. TemplateControl.LoadControl Method (String)

Click here for further information

MSDN, Microsoft

2. An Extensive Examination of User Controls

Click here for further information

MSDN, Microsoft

Question 23 / 75 Mark for Review

Page 56: 70562 (1)

You create a Web application by using Microsoft ASP.NET 3.5. You write the following code to create a template control:

[ParseChildren(true)] public class EmployeeViewer : Control, INamingContainer { public Employee Employee {get; set; }

[TemplateContainer(typeof(EmployeeTemplateContainer))] public ITemplate EmployeeTemplate {get; set; }

protected override void CreateChildControls() { } }

public class EmployeeTemplateContainer : Control, INamingContainer { public Employee Employee {get; set; } }

You need to implement the CreateChildControls method of the EmployeeViewer class so that content specified in the EmployeeTemplate property is rendered by the EmployeeViewer control.

Which code segment should you use?

if (this.EmployeeTemplate == null){this.Controls.Clear();EmployeeTemplateContainer container = new EmployeeTemplateContainer(){Employee = this.Employee;};this.Controls.Add(container);}

if (this.EmployeeTemplate == null){this.Controls.Clear();EmployeeTemplateContainer container = new EmployeeTemplateContainer(){Employee = this.Employee;};this.EmployeeTemplate.InstantiateIn(container);this.Controls.Add(container);}

if (this.EmployeeTemplate != null){this.Controls.Clear();EmployeeTemplateContainer container = new EmployeeTemplateContainer(){Employee = this.Employee;};this.Controls.Add(container);

Page 57: 70562 (1)

}

if (this.EmployeeTemplate != null){this.Controls.Clear();EmployeeTemplateContainer container = new EmployeeTemplateContainer(){Employee = this.Employee;};this.EmployeeTemplate.InstantiateIn(container);this.Controls.Add(container);}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-010 Jump to Question ID

Question 23 Explanation:

You should first determine whether the EmployeeTemplate property of the

EmployeeViewer class returns a null reference. If it does not, this means that you

should render its contents. To do this, you must first create an instance of the

template's container, which is EmployeeTemplateContainer. A template container allows

you to store all of the template's content into a single container control. This allows you

to render the content by simply adding the container to the templated control's

hierarchy. To place the template into the container, you should call the InstantiateIn

method of EmployeeTemplate, passing to the method an instance of the container into

which the template will be placed. This causes all markup between the

<EmployeeTemplate> and </EmployeeTemplate> tags to be placed into the

EmployeeTemplateContainer instance. You should then add the

EmployeeTemplateContainer instance to the EmployeeViewer control's hierarchy.

You should not instantiate the template into its container if the EmployeeTemplate

property returns a null reference. A null reference indicates that there is no template

content to place in the container.

You should not add the template container to the EmployeeViewer control's hierarchy

without first instantiating the template into its container. Otherwise, the markup

specified between the <EmployeeTemplate> and <EmployeeTemplate> tags will not get

rendered.

Page 58: 70562 (1)

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.3 Create and consume custom controls.

References:

1. Developing a Templated Control

Click here for further information

MSDN, Microsoft

2. Building Templated Custom ASP.NET Server Controls

Click here for further information

MSDN, Microsoft

Question 24 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. Your application displays order information from an XML file that does not contain an inline schema. A DataSet-compatible schema is stored in an XSD file. The schema defines a subset of the nodes that exist in the XML file. This schema should not be modified.

You need to load the XML data so that it can be navigated relationally and with the XML Document Object Model (DOM).

What should you do?

Page 59: 70562 (1)

Load the XML file into a DataSet instance.Create an XmlDataDocument instance from the DataSet instance.

Load the XSD file into a DataSet instance.Load the XML file into the DataSet instance by using the InferSchema read mode.Create an XmlDataDocument instance from the DataSet instance.

Load the XSD file into a DataSet instance.Create an XmlDataDocument instance from the DataSet instance.Load the XML file into the XmlDataDocument instance.

Load the XSD file and XML file into a DataSet instance.Create an XmlDataDocument instance from the DataSet instance.Load the XML file into the XmlDataDocument instance.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-061 Jump to Question ID

Question 24 Explanation:

You should synchronize a DataSet instance with an XmlDataDocument instance. The

DataSet class allows you to expose XML data relationally. The XmlDataDocument class

allows you to navigate data relationally and with the XML DOM. You should first load the

XSD file into a DataSet instance. This defines the schema for the DataSet instance. You

should then call the XmlDataDocument constructor, passing to it the DataSet instance

that should be synchronized. Finally, you should load the XML data into the

XmlDataDocument instance. This allows the entire XML data to be navigated, while

allowing only the nodes defined in the XSD schema to be navigated relationally in the

DataSet instance.

Although you should load the XSD file into the DataSet instance, you should not load

the XML file into the DataSet instance by using the InferSchema read mode. This

causes additional schema definitions to be inferred from the XML data and added to the

existing schema.

You should not load the XML file into an XmlDataDocument instance that is

synchronized with a DataSet instance that already contains data. This would throw an

exception.

You should not load the XML file without first loading the XSD file into the DataSet

instance. This would cause the DataSet instance to infer the schema from the XML file.

Page 60: 70562 (1)

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.1 Read and write XML data.

References:

1. Synchronizing a DataSet with an XmlDataDocument

Click here for further information

MSDN, Microsoft

2. Loading a DataSet from XML

Click here for further information

MSDN, Microsoft

3. DataSet and XmlDataDocument Synchronization (ADO.NET)

Click here for further information

MSDN, Microsoft

4. XML Integration with Relational Data and ADO.NET

Click here for further information

MSDN, Microsoft

Question 25 / 75 Mark for Review

Page 61: 70562 (1)

You create a Web application by using Microsoft ASP.NET 3.5. The following code exists in the code-behind file for a page named Admin.aspx:

[WebMethod] public static string GetSessionObject(string key) { return HttpContext.Current.Session[key] as string; }

You need to call the GetSessionObject method from JavaScript, passing to it the value of a TextBox control named _sessionKey. You must display the return value in a browser alert window.

You need to modify the page to accomplish your goal.

What should you do? (Each correct answer presents part of the solution. Choose two.)

Add the following script block to the page:<script language="javascript" type="text/javascript">function GetSessionObject(){var sessionKey = $get('_sessionKey').value;var result = Admin.GetSessionObject(sessionKey);window.alert(result);}</script>

Add the following script block to the page:<script language="javascript" type="text/javascript">function GetSessionObject(){var sessionKey = $get('_sessionKey').value;PageMethods.GetSessionObject(sessionKey, OnSuccess);}function OnSuccess(result){window.alert(result);}</script>

Declare a ScriptManager control on the page as follows:<ScriptManager ID="_scriptManager" runat="server" EnablePageMethods="true"/>

Declare a ScriptManager control on the page as follows:<ScriptManager ID="_scriptManager" runat="server"><Services><asp:ServiceReference Path="Admin.aspx"/></Services></ScriptManager>

Add the following script block to the page:<script language="javascript" type="text/javascript">function GetSessionObject(){var sessionKey = $get('_sessionKey').value;

Page 62: 70562 (1)

var result = PageMethods.GetSessionObject(sessionKey);window.alert(result);}</script>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-024 Jump to Question ID

Question 25 Explanation:

You should declare a ScriptManager control on the page as follows:

<ScriptManager ID="_scriptManager" runat="server" EnablePageMethods="true"/>

The EnablePageMethods property specifies whether page methods are enabled for the

page. Page methods are public static methods that have the WebMethod attribute

applied. These methods can be called from JavaScript through AJAX requests. Setting

the EnablePageMethods property to true allows page methods to be called as Web

methods from a script on that page as if they were part of a Web service, but you do

not have to create a separate .asmx file.

You should add the following script block to the page:

<script language="javascript" type="text/javascript">

function GetSessionObject()

{

var sessionKey = $get('_sessionKey').value;

PageMethods.GetSessionObject(sessionKey, OnSuccess);

}

function OnSuccess(result)

{

window.alert(result);

}

</script>

This script calls the GetSessionObject function of the PageMethods Asynchronous

JavaScript and XML (AJAX) object. This function internally makes an AJAX request to

the server to invoke the corresponding GetSessionObject methods. When the

EnablePageMethods property of the ScriptManager class is set to true, ASP.NET AJAX

automatically generates functions that have the same names as the page methods

Page 63: 70562 (1)

defined for the page. The first parameters to a function match the parameters to the

corresponding page method. In addition, the function defines another parameter that

specifies a callback function to invoke when the AJAX request completes. The parameter

to the callback function is the return value from the page method.

You should not declare a ScriptManager control on the page as follows:

<ScriptManager ID="_scriptManager" runat="server">

<Services>

<asp:ServiceReference Path="Admin.aspx"/>

</Services>

</ScriptManager>

This declaration attempts to reference a Web service that can be called by AJAX

requests. In this scenario, Admin.aspx does not implement a Web service.

You should not add the following script block to the page:

<script language="javascript" type="text/javascript">

function GetSessionObject()

{

var sessionKey = $get('_sessionKey').value;

var result = PageMethods.GetSessionObject(sessionKey);

window.alert(result);

}

</script>

This script does not specify the callback function in the call to

PageMethods.GetSessionObject. The call will return immediately because it is

asynchronous. You must specify the callback function to retrieve the return value from

the page method.

You should not add the following script block to the page:

<script language="javascript" type="text/javascript">

function GetSessionObject()

{

var sessionKey = $get('_sessionKey').value;

var result = Admin.GetSessionObject(sessionKey);

window.alert(result);

}

</script>

Page 64: 70562 (1)

This script attempts to call the GetSessionObject function of an Admin object. However,

to call page methods, you must call functions of the PageMethods object.

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.1 Implement Web Forms by using ASP.NET AJAX.

References:

1. Exposing Web Services to Client Script

Click here for further information

MSDN, Microsoft

2. Calling Web Services from Client Script

Click here for further information

MSDN, Microsoft

3. ScriptManager.EnablePageMethods Property

Click here for further information

MSDN, Microsoft

Question 26 / 75 Mark for Review

Page 65: 70562 (1)

You create a Web site by using Microsoft ASP.NET 3.5. You define a custom configuration section in the Web.config file. You obtain the source file containing the implementation of the configuration section.

You need to configure the application so that the configuration section is processed by ASP.NET.

What should you do?

Add a Reference directive to the Global.asax file and set the VirtualPath attribute to the location of the source file.

Add the source file to the App_Code folder.

Add a Register directive to the Global.asax file and set the Src attribute to the location of the source file.

Add the source file to the project as an embedded resource.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-073 Jump to Question ID

Question 26 Explanation:

You should add the file to the App_Code folder of the project. The App_Code folder

allows you to store utility classes for use in a Web site project. Code placed in this

folder is dynamically compiled into an assembly. This allows ASP.NET to process the

custom configuration section when it processes the Web.config file.

You should not add the source file to the project as an embedded resource. Embedded

resources are not compiled. You must compile the source file so that ASP.NET can

process the custom configuration section.

You should not add a Reference directive to the Global.asax file. This directive instructs

ASP.NET to dynamically compile a referenced page or user control when the requesting

page is compiled. This allows you to programmatically interact with the referenced page

or user control from the file in which the directive exists. Reference directives are not

supported in the Global.asax file.

You should not add a Register directive to the Global.asax file. This directive allows you

to register server controls and user controls on a page. Register directives are not

supported in the Global.asax file.

Page 66: 70562 (1)

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.4 Implement business objects and utility classes.

References:

1. Shared Code Folders in ASP.NET Web Sites

Click here for further information

MSDN, Microsoft

Question 27 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The application is part of a solution that contains a Windows Communication Foundation (WCF) service project. The Web application must make calls to a service defined in the WCF service project. You plan to host the Web application on a separate server from the WCF service. The WCF service must execute remotely.

You need to add a reference to the WCF service.

What should you do?

Add an assembly reference to the project.

Add a project reference to the project.

Add a Web reference to the project.

Page 67: 70562 (1)

Add a service reference to the project.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-068 Jump to Question ID

Question 27 Explanation:

You should add a service reference to the project. This allows you to create a proxy

class for a WCF service. When you make calls to methods defined in the proxy class,

messages are sent to the remote service for invocation.

You should not add a Web reference to the project. A Web reference allows you to

create proxy classes for Extensible Markup Language (XML) Web services. In this

scenario, you need to create a proxy class for a WCF service.

You should not add a project reference to the project. Although project references allow

you to reference assemblies from projects that are defined in the same solution, this

would cause your application to execute the WCF service code locally.

You should not add an assembly reference to the project. Although assembly references

allow you to execute code defined in other assemblies, this would cause your

application to execute the WCF service code locally.

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.3 Call a Windows Communication Foundation (WCF) service or a Web service from an

ASP.NET Web page.

References:

Page 68: 70562 (1)

1. Managing References

Click here for further information

MSDN, Microsoft

2. Add Service Reference Dialog Box

Click here for further information

MSDN, Microsoft

3. How to: Add a Reference to a Web Service

Click here for further information

MSDN, Microsoft

Question 28 / 75 Mark for Review

You are implementing a server control named Survey that displays survey questions. The control must support data binding and paging. You must be able to page data by using a DataPager control.

You need to create the class declaration for the control.

Which code segment should you use?

[DataObject]public class Survey : WebControl{}

public class Survey : DataPager, IDataItemContainer{}

public class Survey : DataBoundControl, IPageableItemContainer{}

[DataObject]public class Survey : Control{}

Page 69: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-025 Jump to Question ID

Question 28 Explanation:

You should derive the class from DataBoundControl and implement the

IPageableItemContainer interface. This interface defines methods, properties, and

events that the DataPager control relies upon. For example, the DataPager control calls

the SetPageProperties method of the interface whenever the DataPager control needs to

update page-related properties.

You should not derive the class from DataPager and implement the IDataItemContainer

interface. The IDataItemContainer interface allows data bound controls to identify a

data item for data binding operations. You must implement the IPageableItemContainer

interface, and the DataPager class does not implement this interface.

You should not derive the class from Control without explicitly implementing the

IPageableItemContainer interface. The Control class does not implement this interface.

The DataObject attribute marks a type as one that can be bound to the

ObjectDataSource control. This attribute does not enable a control to be paged by the

DataPager control.

You should not derive the class from WebControl without explicitly implementing the

IPageableItemContainer interface. The WebControl class does not implement this

interface.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.1 Implement data-bound controls.

Page 70: 70562 (1)

References:

1. DataPager Class

Click here for further information

MSDN, Microsoft

2. IPageableItemContainer Interface

Click here for further information

MSDN, Microsoft

Question 29 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following code exists:

public class Employee { public string Name {get; set;} public Address Address {get; set;} }

public class Address { public string City {get; set;} public string State {get; set;} public string Zip {get; set;} }

You define a GridView control as follows and bind it to a collection of Employee instances:

<asp:GridView ID="_gridView" runat="server"> </asp:GridView>

You need to display the City property of the Address class and the Name property of the Employee class in separate columns.

Which declaration should you use?

Page 71: 70562 (1)

<asp:GridView ID="_gridView" runat="server" AutoGenerateColumns="false"><Columns><asp:BoundField HeaderText="City" DataField="Employee.Address.City"/><asp:BoundField HeaderText="Name" DataField="Employee.Name"/></Columns></asp:GridView>

<asp:GridView ID="_gridView" runat="server"><Columns><asp:TemplateField HeaderText="City"><ItemTemplate><%#Eval("Employee.Address.City")%></ItemTemplate></asp:TemplateField></Columns></asp:GridView>

<asp:GridView ID="_gridView" runat="server" AutoGenerateColumns="false"><Columns><asp:BoundField HeaderText="City" DataField="Address.City"/><asp:BoundField HeaderText="Name" DataField="Name"/></Columns></asp:GridView>

<asp:GridView ID="_gridView" runat="server"><Columns><asp:TemplateField HeaderText="City"><ItemTemplate><%#Eval("Address.City")%></ItemTemplate></asp:TemplateField></Columns></asp:GridView>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-017 Jump to Question ID

Question 29 Explanation:

You should use the following declaration:

<asp:GridView ID="_gridView" runat="server">

<Columns>

<asp:TemplateField HeaderText="City">

<ItemTemplate>

<%#Eval("Address.City")%>

</ItemTemplate>

</asp:TemplateField>

</Columns>

Page 72: 70562 (1)

</asp:GridView>

This adds a TemplateField column to the GridView control. A TemplateField column gives

you more flexibility in displaying data. In this scenario, Employee instances are bound

to the GridView control. This means that the current data context for a given row is an

Employee instance. To display the City property of the Address class, you must use the

#Eval data binding syntax to bind to Address.City. Eval is a method of the Page class

that is used to evaluate a data binding expression. By default, the

AutoGenerateColumns property of the GridView control is set to true, which is why you

do not need to explicitly create a column to bind to the Name property. When

AutoGenerateColumns is set to true, the GridView control automatically creates

BoundField columns and binds to immediate properties of the instances being bound.

You should not use the following declaration:

<asp:GridView ID="_gridView" runat="server" AutoGenerateColumns="false">

<Columns>

<asp:BoundField HeaderText="City" DataField="Address.City"/>

<asp:BoundField HeaderText="Name" DataField="Name"/>

</Columns>

</asp:GridView>

Only immediate properties of an instance can be displayed in a BoundField column. In

this scenario, Address.City is not an immediate property of the Employee class. Only

Address and Name are immediate properties of the Employee class.

You should not use the following declaration:

<asp:GridView ID="_gridView" runat="server">

<Columns>

<asp:TemplateField HeaderText="City">

<ItemTemplate>

<%#Eval("Employee.Address.City")%>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

The Eval method specifies Employee.Address.City as the parameter. However, it should

only specify Address.City. The current data context is an Employee instance.

You should not use the following declaration:

Page 73: 70562 (1)

<asp:GridView ID="_gridView" runat="server" AutoGenerateColumns="false">

<Columns>

<asp:BoundField HeaderText="City" DataField="Employee.Address.City"/>

<asp:BoundField HeaderText="Name" DataField="Employee.Name"/>

</Columns>

</asp:GridView>

Only immediate properties of an instance can be displayed in a BoundField column. In

this scenario, Employee.Address.City and Employee.Name are not immediate properties

of the Employee class. Only Address and Name are immediate properties of the

Employee class. The current data context is an Employee instance.

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.5 Bind controls to data by using data binding syntax.

References:

1. Data Binding Expression Syntax

Click here for further information

MSDN, Microsoft

2. BoundField.DataField Property

Click here for further information

MSDN, Microsoft

3. Creating a Custom Column in a GridView Web Server Control

Click here for further information

MSDN, Microsoft

Page 74: 70562 (1)

Question 30 / 75 Mark for Review

You create a mobile Web application by using Microsoft ASP.NET 3.5. The following method exists in the code-behind file for a page:

public bool IsGpsSupported(MobileCapabilities capabilities, String optionalArgument) { return Request.Headers["GPS"] == Boolean.TrueString; }

This method determines whether the browser's device supports global positioning system (GPS).

You must render a mobile Panel control that meets the following requirements:

* If the device supports GPS, the Panel control should render a custom control named Map. * Otherwise, the Panel control should display the following text: GPS is not supported on this device.

You need to declare the mobile Panel control.

What should you do?

Add the following configuration to the Web.config file:<deviceFilters><filter name="IsGpsSupported" argument="GPS"/></deviceFilters>

Add the following markup to the page:<mobile:Panel ID="_panel" runat="server"><mobile:DeviceSpecific ID="_deviceSpecific" runat="server"><Choice Filter="Headers"><ContentTemplate><cc1:Map ID="_map" runat="server"/></ContentTemplate></Choice><Choice><ContentTemplate>GPS is not supported on this device.</ContentTemplate></Choice>

Page 75: 70562 (1)

</mobile:DeviceSpecific></mobile:Panel>

Add the following configuration to the Web.config file:<deviceFilters><filter name="IsGpsSupported" compare="GPS"/></deviceFilters>

Add the following markup to the page:<mobile:Panel ID="_panel" runat="server"><mobile:DeviceSpecific ID="_deviceSpecific" runat="server"><Choice Filter="IsGpsSupported:true"><ContentTemplate><cc1:Map ID="_map" runat="server"/></ContentTemplate></Choice><Choice><ContentTemplate>GPS is not supported on this device.</ContentTemplate></Choice></mobile:DeviceSpecific></mobile:Panel>

Add the following markup to the page:<mobile:Panel ID="_panel" runat="server"><mobile:DeviceSpecific ID="_deviceSpecific" runat="server"><Choice Filter="GPS"><ContentTemplate><cc1:Map ID="_map" runat="server"/></ContentTemplate></Choice><Choice><ContentTemplate>GPS is not supported on this device.</ContentTemplate></Choice></mobile:DeviceSpecific></mobile:Panel>

Add the following markup to the page:<mobile:Panel ID="_panel" runat="server"><mobile:DeviceSpecific ID="_deviceSpecific" runat="server"><Choice Filter="IsGpsSupported"><ContentTemplate><cc1:Map ID="_map" runat="server"/></ContentTemplate></Choice><Choice><ContentTemplate>GPS is not supported on this device.</ContentTemplate></Choice></mobile:DeviceSpecific></mobile:Panel>

Page 76: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-038 Jump to Question ID

Question 30 Explanation:

You should add a DeviceSpecifc control to the Panel control. The DeviceSpecific control

allows you to render different content for different devices. The DeviceSpecific control

supports one or more Choice elements that define the criteria for rendering to a specific

device. The Filter attribute of the Choice element specifies the criteria that the device

must meet for the content of that Choice element to be rendered. The ASP.NET mobile

framework first attempts to locate a method in the containing page or user control that

matches the value of the Filter attribute. That method must match a pre-defined

signature. The first parameter must be a MobileCapabilities instance that represents the

capabilities of the browser. The second parameter must be a String instance that

represents an optional argument. If the mobile framework cannot find such a method, it

evaluates the deviceFilters section of the Web.config file. If it finds a filter element

whose name attribute matches the Filter attribute of the Choice element, the mobile

framework uses that filter to determine whether the criteria are met. In this scenario, a

method named IsGpsSupported that matches the required signature is defined in the

code-behind file for the page. Therefore, that method will be used to determine whether

the criteria are met. If the filter is not present, that choice is selected by default.

You should not specify a value for the Filter attribute of the Choice element that does

not match either the name of a filter in the Web.config file or the name of a method in

the current page. Otherwise, the mobile framework would not be able to evaluate the

filter to determine if the browser's device supports GPS.

Objective:

List all questions for this objective</P< td>

Targeting Mobile Devices

Sub-Objective:

6.2 Control device-specific rendering.

References:

Page 77: 70562 (1)

1. Device-Specific Rendering

Click here for further information

MSDN, Microsoft

2. Device Evaluation Methods

Click here for further information

MSDN, Microsoft

Question 31 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following event handler handles the AsyncPostBackError event of a ScriptManager control named _scriptManager:

protected void OnError(object sender, AsyncPostBackErrorEventArgs e) { _scriptManager.AsyncPostBackErrorMessage = "A system error has occurred"; }

You must display the value of the AsyncPostBackErrorMessage property in a browser alert window when an unhandled exception occurs on the server during an asynchronous request.

You need to write the JavaScript code.

Which code segment should you use?

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(OnLoaded);function OnLoaded(sender, args){var dataItems = args.get_dataItems();var errorMessage = dataItems[' AsyncPostBackErrorMessage'];if (errorMessage != null){window.alert(errorMessage);}}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(OnEndRequest);

Page 78: 70562 (1)

function OnEndRequest(sender, args){if (args.get_error() != undefined && args.get_error().httpStatusCode == '500'){var errorMessage = args.get_error().message;args.set_errorHandled(true);window.alert(errorMessage);}}

Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(OnLoading);function OnLoading(sender, args){var dataItems = args.get_dataItems();var errorMessage = dataItems[' _scriptManager.AsyncPostBackErrorMessage'];if (errorMessage != null){window.alert(errorMessage);}}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(OnEndRequest);function OnEndRequest(sender, args){if (args.get_error() != undefined && args.get_error().httpStatusCode == '500'){var dataItems = args.get_dataItems();var errorMessage = dataItems[' AsyncPostBackErrorMessage'];args.set_errorHandled(true);window.alert(errorMessage);}}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-023 Jump to Question ID

Question 31 Explanation:

You should use the following code segment:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(OnEndRequest);

function OnEndRequest(sender, args)

{

if (args.get_error() != undefined && args.get_error().httpStatusCode == '500')

{

var errorMessage = args.get_error().message;

args.set_errorHandled(true);

Page 79: 70562 (1)

window.alert(errorMessage);

}

}

This code creates an event handler for the endRequest Asynchronous JavaScript and

XML (AJAX) event. This event is raised after an AJAX request ends. The event handler

defines an EndRequestEventArgs object that contains an error property, which returns a

JavaScript Error object if an error occurred. The Error object contains a message

property, which specifies the error message associated with the error. ASP.NET

automatically sets this property to the value of the AsyncPostBackErrorMessage

property of the ScriptManager control.

You should not use the following code segment:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(OnEndRequest);

function OnEndRequest(sender, args)

{

if (args.get_error() != undefined && args.get_error().httpStatusCode == '500')

{

var dataItems = args.get_dataItems();

var errorMessage = dataItems[' AsyncPostBackErrorMessage'];

args.set_errorHandled(true);

window.alert(errorMessage);

}

}

This code accesses the dataItems property of the EndRequestEventArgs object. The

dataItems property contains all data items registered by calls to the RegisterDataItem

method of the ScriptManager class. In this scenario, the code does not call the

RegisterDataItem method, so the dataItems property should be empty.

You should not use the following code segment:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(OnLoading);

function OnLoading(sender, args)

{

var dataItems = args.get_dataItems();

var errorMessage = dataItems[' _scriptManager.AsyncPostBackErrorMessage'];

if (errorMessage != null)

{

window.alert(errorMessage);

}

}

Page 80: 70562 (1)

This code handles the pageLoading AJAX event and accesses the dataItems property of

the PageLoadingEventArgs object. The dataItems property contains all data items

registered by calls to the RegisterDataItem method of the ScriptManager class. In this

scenario, the code does not call the RegisterDataItem method, so the dataItems

property should be empty.

You should not use the following code segment:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(OnLoaded);

function OnLoaded(sender, args)

{

var dataItems = args.get_dataItems();

var errorMessage = dataItems[' AsyncPostBackErrorMessage'];

if (errorMessage != null)

{

window.alert(errorMessage);

}

}

This code handles the pageLoaded AJAX event and accesses the dataItems property of

the PageLoadedEventArgs object. The dataItems property contains all data items

registered by calls to the RegisterDataItem method of the ScriptManager class. In this

scenario, the code does not call the RegisterDataItem method, so the dataItems

property should be empty.

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.2 Interact with the ASP.NET AJAX client-side library.

References:

1. ScriptManager.AsyncPostBackErrorMessage Property

Page 81: 70562 (1)

Click here for further information

MSDN, Microsoft

2. Customizing Error Handling for ASP.NET UpdatePanel Controls

Click here for further information

MSDN, Microsoft

3. ScriptManager Control Overview

Click here for further information

MSDN, Microsoft

4. Sys.WebForms.EndRequestEventArgs error Property

Click here for further information

MSDN, Microsoft

Question 32 / 75 Mark for Review

You create a Web site by using Microsoft ASP.NET 3.5. You create a server control named Chart in a file named Chart.cs. This file is contained in the App_Code folder. The Chart class is part of the BcdTrain.WebControls namespace.

You need to configure a page so that you can use this control declaratively.

Which directive should you use?

<%@ Register TagPrefix="cust" Namespace="Bcdtrain.WebControls"/>

<%@ Reference Control="BcdTrain.WebControls.Chart" VirtualPath="~/App_Code"/>

<%@ Reference Control="BcdTrain.WebControls.Chart, App_Code"/>

<%@ Register

Page 82: 70562 (1)

TagName="Chart" Namespace="Bcdtrain.WebControls" Assembly="App_Code"/>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-059 Jump to Question ID

Question 32 Explanation:

You should use the Register directive. This directive allows you to register server

controls and user controls on a page. When registering server controls, you must set

the TagPrefix, Namespace, and Assembly attributes. The TagPrefix attribute specifies

the prefix of the element that represents the namespace containing the control. The

Namespace attribute specifies the namespace that the prefix represents. The Assembly

attribute specifies the assembly that contains the control. In this scenario, the control

exists in the App_Code folder. When code is placed in the App_Code folder, the

assembly is assumed to be one that is automatically generated for code in the

App_Code folder. In this case, you do not need to specify the Assembly attribute.

You should not set the TagName attribute of the Register directive. When registering

user controls, you must set the TagPrefix, TagName and Src attributes. The TagName

attribute specifies the element name that represents the user control. The Src attribute

specifies the path to the user control file.

You should not use the Reference directive. This directive instructs ASP.NET to

dynamically compile a referenced page or user control when the requesting page is

compiled. This allows you to programmatically interact with the referenced page or user

control from the file in which the directive exists.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

Page 83: 70562 (1)

2.3 Create and consume custom controls.

References:

1. @ Register

Click here for further information

MSDN, Microsoft

2. @ Reference

Click here for further information

MSDN, Microsoft

Question 33 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following code exists:

using (XmlWriter writer = XmlWriter.Create("Data.xml")) { writer.WriteStartElement("TaxMan"); writer.WriteAttributeString("Version", "3.0.0.0"); writer.WriteAttributeString("Year", "2008"); writer.WriteElementString("Description", "2008 Taxation System"); writer.WriteEndElement(); }

You need to identity the output of this code.

Which XML output would this code produce?

<TaxMan Version="3.0.0.0" Year="2008"><Description Value="2008 Taxation System"/></TaxMan>

<TaxMan Description="2008 Taxation System"><Version>3.0.0.0</Version><Year>2008</Year></TaxMan>

Page 84: 70562 (1)

<TaxMan Version="3.0.0.0" Year="2008"><Description>2008 Taxation System</Description></TaxMan>

<TaxMan Version="3.0.0.0" Year="2008"/><Description>2008 Taxation System</Description>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-013 Jump to Question ID

Question 33 Explanation:

The code writes the following XML to the file:

<TaxMan Version="3.0.0.0" Year="2008">

<Description>2008 Taxation System</Description>

</TaxMan>

The first line of code creates an XmlWriter instance that writes to an XML file named

Data.xml. The second line of code calls the WriteStartElement method of the XmlWriter

instance, producing the following output in the data stream: <TaxMan. The third and

fourth lines of code call the WriteAttributeString method of the XmlWriter instance,

producing the following output in the data stream: <TaxMan Version="3.0.0.0"

Year="2008". The fifth line of code calls the WriteElementString method of the

XmlWriter instance, producing the following output in the data stream: <TaxMan

Version="3.0.0.0" Year="2008"><Description>2008 Taxation System</Description>.

The final line of code calls the WriteEndElement method, which closes the start element

and produces the following output in the data stream: <TaxMan Version="3.0.0.0"

Year="2008"><Description>2008 Taxation System</Description></TaxMan>

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

Page 85: 70562 (1)

3.1 Read and write XML data.

References:

1. Writing XML with the XmlWriter

Click here for further information

MSDN, Microsoft

2. Creating XML Writers

Click here for further information

MSDN, Microsoft

3. Writing Elements

Click here for further information

MSDN, Microsoft

4. Writing Attributes

Click here for further information

MSDN, Microsoft

Question 34 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following configuration exists in the Web.config file:

<profile> <properties> <add name="Theme" /> </properties> </profile>

The following code exists in the code-behind file for a page:

public partial class SetupInfo : System.Web.UI.Page { }

You need to programmatically set the page's theme to the current user profile's Theme property.

Page 86: 70562 (1)

Which code segment should you use?

protected override void OnPreInit(EventArgs e){this.Theme = Profile.Theme;base.OnPreInit(e);}

protected void Page_Load(object sender, EventArgs e){this.Theme = Profile.Theme;}

protected override void OnPreRender(EventArgs e){string theme = this.Theme;this.Theme = Context["Profile.Properties.Theme"];base.OnPreRender(e);this.Theme = theme;}

protected override void OnInit(EventArgs e){base.OnInit(e);this.Theme = Context["Profile.Theme"];}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-007 Jump to Question ID

Question 34 Explanation:

You should override the OnPreInit method of the Page class and set the Theme property

to the Profile.Theme instance. User profiles are strongly-typed. In this scenario, a single

user profile property named Theme is specified in the Web.config file. This configuration

allows you to access the property through the Profile.Theme instance. Profile is a

property of the Page class. When dynamically changing a page's theme, you must

either override the OnPreInit method or handle the PreInit event and set the theme.

You must dynamically set a page's theme before the page is initialized. The OnPreInit

method is called and the PreInit event is raised before a page is initialized.

You should not set the page's theme in the Page_Load event handler. This event handler

is automaticaly associated with the Load event of a page. This event is raised after a

page is initialized and loaded. However, you must dynamically set a page's theme

Page 87: 70562 (1)

before the page is initialized.

You should not override the OnInit method to set the page's theme. This method is

called after a page is initialized, but before it is loaded. However, you must dynamically

set a page's theme before the page is initialized. Also, profile properties are not

automatically stored as items in the current HttpContext instance. Therefore, you

should not attempt to access an item named Profile.Properties.Theme from this

instance.

You should not override the OnPreRender method to set the page's Theme. This method

is called just before a page is rendered. However, you must dynamically set a page's

theme before the page is initialized. Also, profile properties are not automatically stored

as items in the current HttpContext instance. Therefore, you should not attempt to

access an item named Profile.Theme from this instance.

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.1 Customize the layout and appearance of a Web page.

References:

1. ASP.NET Profile Properties Overview

Click here for further information

MSDN, Microsoft

Question 35 / 75 Mark for Review

Page 88: 70562 (1)

You create a Web application by using Microsoft ASP.NET 3.5. You create a DataSet instance named dataSet from the following XML data:

<Vehicles> <Car Vin="1HGCDXXX4"> <Car Vin="1TTGCDXXX3"> <Truck Vin="1SVCDXXX2"> <Suv Vin="1SVCDXXX0"> <Minivan Vin="1TTGCDXXX1"> <Minivan Vin="1HGCDXXX5"> </Vehicles>

In this XML, the Vin attribute represents a vehicle identification number (VIN) for a vehicle. A method named ProcessVin accepts a VIN as a parameter.

You need to create a DataTableReader instance and call the ProcessVin method for each vehicle.

Which code segment should you use?

using (DataTableReader reader = dataSet.CreateDataReader()){do{ProcessVin(reader["Vin"]);} while (reader.NextResult());}

using (DataTableReader reader = dataSet.CreateDataReader()){do{while (reader.NextResult()){ProcessVin(reader.GetString(0));}} while (reader.Read());}

using (DataTableReader reader = dataSet.CreateDataReader()){do{while (reader.Read()){ProcessVin(reader["Vin"]);}} while (reader.NextResult());}

using (DataTableReader reader = dataSet.CreateDataReader()){while (reader.NextResult()){reader.Read();ProcessVin(reader.GetString(0));

Page 89: 70562 (1)

}}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-014 Jump to Question ID

Question 35 Explanation:

You should use a do...while loop to navigate each result set in the DataSet instance. To

navigate each result set, you must first create a DataTableReader instance by calling

the CreateDataReader method of the DataSet class. This creates a reader that can be

used to navigate the rows of each DataTable instance in the DataSet instance. When

you first call the method, the reader is positioned on the first DataTable instance. By

calling the Read method, you position the reader on the first row. You should then call

the ProcessVin method for that row. To access the Vin field of that row, you can call the

GetString method and pass the value 0 as a parameter, or you can pass the value Vin to

the property indexer. If you call the GetString method, the value 0 specifies the first

field in the row. You should call the Read method for each row. You can accomplish this

by placing the call to the Read method in a while loop. If the Read method returns false,

then there are no more rows to read in the current result set.

You should not call the NextResult method of the DataTableReader instance inside a

while loop before processing the rows of the first result set. When you create the

DataTableReader instance, it is positioned on the first result set. If you call the

NextResult method immediately after creating the instance, you position the reader on

the second result set.

You should not attempt to access the fields of a row before you call the Read method of

the DataTableReader class. The Read method advances the reader to the next row of a

result set. When you create the DataTableReader instance, it is positioned on the first

result set, but it is not positioned on the first row. You must call the Read method to

advance the reader to the first row.

You should not call the Read method of the DataTableReader instance inside a do...while

loop and attempt to access the rows inside the loop. You must call the Read method

before accessing the rows. Also, you should call the NextResult method only after the

Read method returns false, which indicates that there are no more rows in the current

result set.

Page 90: 70562 (1)

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.2 Manipulate data by using DataSet and DataReader objects.

References:

1. Creating and Using a DataTableReader

Click here for further information

MSDN, Microsoft

2. Navigating the Contents of a DataTableReader

Click here for further information

MSDN, Microsoft

3. Creating a DataTableReader

Click here for further information

MSDN, Microsoft

Question 36 / 75 Mark for Review

You create a Web site by using Microsoft ASP.NET 3.5. The following code exists in the Global.asax file:

void Application_Error(object sender, EventArgs e) { Exception exception = Server.GetLastError(); Exception ex = exception; if (exception is HttpUnhandledException)

Page 91: 70562 (1)

{ ex = exception.InnerException; }

UnhandledExceptionWebErrorEvent evt = new UnhandledExceptionWebErrorEvent(ex); evt.Raise(); }

When this code executes, you must send an e-mail to [email protected] with the details of the exception. The UnhandledExceptionWebErrorEvent class exists in the App_Code folder. It is part of the BcdTrain.WebEvents namespace. The root Web.config file is not modified from its default configuration.

You need to configure health monitoring in the application's Web.config file to accomplish your goal.

Which configuration should you use?

<healthMonitoring enabled="true"><eventMappings><add name="UnhandledExceptionWebErrorEvent" type="WebErrorEvent"/></eventMappings><rules><add name="Email Unhandled Exceptions" eventName="UnhandledExceptionWebErrorEvent"provider="SimpleMailProvider" profile="Default"custom="mailto:[email protected]"/></rules></healthMonitoring>

<healthMonitoring enabled="true"><eventMappings><add name="Unhandled Exceptions" type="BcdTrain.WebEvents.UnhandledExceptionWebErrorEvent, App_Code"/></eventMappings><rules><add name="Email Unhandled Exceptions" eventName="Unhandled Exceptions"provider="SimpleMailProvider" profile="Critical"custom="mailto:[email protected]"/></rules></healthMonitoring>

<healthMonitoring enabled="true"><eventMappings><add

Page 92: 70562 (1)

name="Unhandled Exceptions" type="BcdTrain.WebEvents.UnhandledExceptionWebErrorEvent, App_Code"/></eventMappings><providers><add name="SimpleMailProvider" type="System.Web.Management.SimpleMailWebEventProvider,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" from="[email protected]"to="[email protected]"bufferMode="Critical Notification"/></providers><rules><add name="Email Unhandled Exceptions" eventName="Unhandled Exceptions"provider="SimpleMailProvider" profile="Critical"/></rules></healthMonitoring>

<healthMonitoring enabled="true"><eventMappings><add name=" WebErrorEvent" type=" UnhandledExceptionWebErrorEvent"/></eventMappings><rules><add name="Email Unhandled Exceptions" eventName="WebErrorEvent"provider="SimpleMailProvider" profile="Default"custom="mailto:[email protected]"/></rules></healthMonitoring>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-035 Jump to Question ID

Question 36 Explanation:

You should use the following configuration:

<healthMonitoring enabled="true">

<eventMappings>

<add

name="Unhandled Exceptions"

Page 93: 70562 (1)

type="BcdTrain.WebEvents.UnhandledExceptionWebErrorEvent, App_Code"/>

</eventMappings>

<providers>

<add

name="SimpleMailProvider"

type="System.Web.Management.SimpleMailWebEventProvider,

System.Web,Version=2.0.0.0,Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"

from="[email protected]"

to="[email protected]"

bufferMode="Critical Notification"/>

</providers>

<rules>

<add

name="Email Unhandled Exceptions"

eventName="Unhandled Exceptions"

provider="SimpleMailProvider"

profile="Critical"/>

</rules>

</healthMonitoring>

Health monitoring defines events to be monitored, providers that deliver the events,

and rules that map events to providers. This configuration defines an event that maps

to the UnhandledExceptionWebErrorEvent class. Only events that are defined in the

eventMappings element are delivered to a provider. The name attribute of the add

element specifies a name for the event. The type attribute specifies the fully-qualified

type name of the class. This configuration defines an e-mail provider that is already

implemented by the base class library. This provider is the SimpleMailWebEventProvider

class. Only providers that are defined in the providers element are used to deliver

events. The name attribute of the add element specifies a name for the provider. The

type attribute specifies the fully-qualified type name of the class that implements the

provider. The SimpleMailWebEventProvider class also uses from and to attributes to

specify the sender and recipient of the e-mail message that gets sent. Lastly, this

configuration defines a rule that maps the event being monitored to the e-mail provider.

Only rules that are defined in the rules element are processed. The name attribute of

the add element specifies a name for the rule. The eventName attribute specifies the

name of the event to which the rule applies. The provider attribute specifies the name

of the provider that will deliver the associated event.

You must define the event, the e-mail provider, and the rule. The default configuration

of the root Web.config file does not define an e-mail provider in the eventMappings

element, even though one is implemented in the base class library.

Page 94: 70562 (1)

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.6 Monitor Web applications.

References:

1. ASP.NET Health Monitoring Overview

Click here for further information

MSDN, Microsoft

2. How to: Send E-mail for Health Monitoring Notifications

Click here for further information

MSDN, Microsoft

Question 37 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. A page in the application contains code that calls Write and Warn methods of the TraceContext class. The code also adds an instance of EventLogTraceListener to the System.Diagnostics.Trace.Listeners collection.

* The Write and Warn methods of the TraceContext class must automatically

write ASP.NET trace messages to the event log.

Page 95: 70562 (1)

You need to configure the application to meet these requirements.

What should you do?

Add the following configuration to the Web.config file:<trace enabled="true" pageOutput="true" localOnly="true" writeToDiagnosticsTrace="true"/>

Add the following Page directive to the page:<%@ Page Trace="true" Debug="false" %>

Add the following configuration to the Web.config file:<trace enabled="true" pageOutput="false" localOnly="true" writeToDiagnosticsTrace="true"/>

Add the following Page directive to the page:<%@ Page Trace="true" Debug="true" %>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-048 Jump to Question ID

Question 37 Explanation:

You should enable ASP.NET tracing by setting the enabled attribute of the trace element

to true in the Web.config file. You should set the pageOutput attribute to false. This

prevents users from viewing trace messages on the page. However, users can still view

trace messages by accessing the trace viewer tool (Trace.axd). To prevent this, you

should set the localOnly attribute to true. This allows only requests from the Web server

itself to access Trace.axd. Finally, you should set the writeToDiagnosticsTrace attribute

to true. This allows messages written through Trace.Write and Trace.Warn method calls

to be forwarded to the diagnostic tracing subsystem. Because code in the page adds an

instance of EventLogTraceListener to the System.Diagnostics.Trace.Listeners collection,

the messages get routed to the event log.

You should not set the pageOutput attribute to true. This would cause ASP.NET trace

messages to be rendered by all pages, which would allow remote users to view the

Page 96: 70562 (1)

messages.

You should not set the Trace attribute of the Page directive to true. This would cause

ASP.NET trace messages to be rendered by the page, which would allow remote users

to view the messages.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.4 Implement tracing of a Web application.

References:

1. Walkthrough: Integrating ASP.NET Tracing with System.Diagnostics Tracing

Click here for further information

MSDN, Microsoft

2. How to: View ASP.NET Trace Information with the Trace Viewer

Click here for further information

MSDN, Microsoft

3. How to: Enable Tracing for an ASP.NET Application

Click here for further information

MSDN, Microsoft

4. ASP.NET Tracing Overview

Click here for further information

MSDN, Microsoft

5. Application-Level ASP.NET Tracing Overview

Click here for further information

MSDN, Microsoft

Page 97: 70562 (1)

Question 38 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following code exists in the application:

public class UserSession { private string _webServer;

public UserSession(string webServer) { _webServer = webServer; }

public DataSet GetUsers() { // Omitted for brevity } }

You must bind the DataSet instance returned from the GetUsers method to a data bound control. The parameter to the UserSession constructor is specified in a query string parameter named WebServer.

You need to configure the ObjectDataSource control to accomplish your goal.

What should you do? (Each correct answer presents part of the solution. Choose two.)

Add the following code to the code-behind file:protected void OnSelect(object sender, ObjectDataSourceSelectingEventArgs e){string webServer = Request.QueryString["WebServer"];e.InputParameters[0] = new UserSession(webServer);}

Programmatically create the ObjectDataSource control as follows:ObjectDataSource dataSource = new ObjectDataSource();dataSource.SelectMethod = "GetUsers";dataSource.Selecting = new ObjectDataSourceSelectingEventHandler(OnSelect);Controls.Add(dataSource);

Programmatically create the ObjectDataSource control as follows:ObjectDataSource dataSource = new ObjectDataSource();dataSource.Created = new ObjectDataSourceObjectEventHandler(OnCreate);dataSource.SelectMethod = "GetUsers";

Page 98: 70562 (1)

QueryStringParameter parameter = new QueryStringParameter();parameter.Name = "webServer";parameter.QueryStringField = "WebServer";dataSource.SelectParameters.Add(parameter);Controls.Add(dataSource);

Declare the ObjectDataSource control as follows:<asp:ObjectDataSource ID="_objectDataSource" runat="server"TypeName="UserSession" SelectMethod="GetUsers"OnObjectCreating="OnCreate"/>

Add the following code to the code-behind file:protected void OnCreate(object sender, ObjectDataSourceEventArgs e){UserSession userSession = new UserSession(Request.QueryString["WebServer"]);e.ObjectInstance = userSession;}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-032 Jump to Question ID

Question 38 Explanation:

You should declare the ObjectDataSource control by setting its TypeName and

SelectMethod properties. The TypeName property specifies the common language

runtime (CLR) type of the object to query. The SelectMethod property specifies a

method of that type that is used to query data. In this scenario, the type name of the

object to query is UserSession, and the method that is used to query data is GetUsers.

You should also handle the ObjectCreating event of the ObjectDataSource control.

Because the UserSession class does not have a default constructor, the

ObjectDataSource control has no idea of what to pass to the constructor as a

parameter. The ObjectCreating event allows you to manually create an instance of

UserSession that the ObjectDataSource control can use. In this case, the parameter to

the constructor is retrieved from a query string parameter named "WebServer". The

event handler for this event defines an ObjectDataSourceEventArgs parameter that

contains a property named ObjectInstance. After manually creating the UserSession

instance, you should set the ObjectInstance property to that instance.

You should not handle the ObjectCreated event. This event is raised after an instance of

the UserSession class is created. In this scenario, you need to manually create the

instance because it does not have a default constructor.

You should not add parameters to the SelectParameters collection of the

Page 99: 70562 (1)

ObjectDataSource control. Parameters added to this collection are passed as

parameters to the method specified in the SelectMethod property. In this scenario, the

GetUsers method is specified in the SelectMethod property, and the GetUsers method

does not accept any parameters.

You should not handle the Selecting event of the ObjectDataSource control. This event

allows you to add, modify, or remove input parameters to the method specified in the

SelectMethod property. In this scenario, the GetUsers method is specified in the

SelectMethod property, and the GetUsers method does not accept any parameters.

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.4 Implement a DataSource control.

References:

1. ObjectDataSource Web Server Control Overview

Click here for further information

MSDN, Microsoft

2. Creating an ObjectDataSource Control Source Object

Click here for further information

MSDN, Microsoft

Question 39 / 75 Mark for Review

Page 100: 70562 (1)

You create a Web application by using Microsoft ASP.NET 3.5. You add two files named Default.aspx.resx and Default.aspx.fr-FR.resx to the App_LocalResources folder. The Default.aspx.resx file contains the following string resource:

Name: WelcomeLabel.Text Value: Hello

The Default.aspx.fr-FR.resx file contains the following string resource:

Name: WelcomeLabel.Text Value: Bonjour

On a page named Default.aspx, you must display text from one of the localized resource files.

You need to declare a Label control to display the text.

Which declaration should you use?

<asp:Label ID="welcomeLabel" runat="server" meta:resourcekey="WelcomeLabel.Text"/>

<asp:Label ID="welcomeLabel"runat="server" Text='<%$ Resources:WelcomeLabel%>'/>

<asp:Label ID="welcomeLabel"runat="server" Text='<%$ Resources:WelcomeLabel, Text%>'/>

<asp:Label ID="welcomeLabel"runat="server"meta:resourcekey="WelcomeLabel"/>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-072 Jump to Question ID

Question 39 Explanation:

You should use the following declaration:

<asp:Label

Page 101: 70562 (1)

ID="welcomeLabel"

runat="server"

meta:resourcekey="WelcomeLabel"/>

This markup sets the meta:resourcekey attribute and specifies a resource key in the

associated local resource file. A local resource file is one that exists in the

App_LocalResources folder and uses the same base name as the containing page. In

this scenario, the page is named Default.aspx. Therefore, Default.aspx.resx and

Default.aspx.fr-FR.resx are considered local resources associated with that page. The

use of the meta:resourcekey attribute is considered implicit localization. With implicit

localization, a resource ID consists of the following naming convention: [Key].

[Property]. The [Key] placeholder represents the resource key, and the [Property]

placeholder represents the resource property. At runtime, ASP.NET searches for

resource keys that are equal to the value of the meta:resourcekey attribute. ASP.NET

then searches for resource properties that match properties of the control. For each

match, ASP.NET sets the value of the property to the value of the corresponding

resource ID. In this scenario, by setting the meta:resourcekey attribute to

WelcomeLabel, ASP.NET substitutes the value of the Text property of the associated

Label control with the value of WelcomeLabel.Text. You can define additional resource

IDs in the local resource file. For example, if you specify WelcomeLabel.Width and

WelcomeLabel.BackColor, ASP.NET substitutes the values of the Width and BackColor

properties with the values of the WelcomeLabel.Width and WelcomeLabel.BackColor

resource IDs, respectively.

You should not use the following declaration:

<asp:Label

ID="welcomeLabel"

runat="server"

Text='<%$ Resources:WelcomeLabel%>'/>

This markup uses explicit localization to set the value of the Text property. However,

there is no resource ID named WelcomeLabel. With explicit localization, you must

specify the resource ID of the resource to substitute. In this scenario, the resource ID is

WelcomeLabel.Text.

You should not use the following declaration:

<asp:Label

ID="welcomeLabel"

runat="server"

meta:resourcekey="WelcomeLabel.Text"/>

Page 102: 70562 (1)

This markup uses implicit localization, but it does not specify the correct resource key.

The meta:resourcekey attribute must specify the resource key, not the resource ID. The

resource key for the WelcomeLabel.Text resource ID is simply WelcomeLabel.

You should not use the following declaration:

<asp:Label

ID="welcomeLabel"

runat="server"

Text='<%$ Resources:WelcomeLabel, Text%>'/>

This markup uses explicit localization, but it does not use the correct resource class and

resource ID. A resource class is the base file name of a resource file. When using local

resources, you do not need to specify the resource class because it is implied by the

name of the page. In this scenario, the resource class is Default and the resource ID is

WelcomeLabel.Text.

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.3 Implement globalization and accessibility.

References:

1. ASP.NET Web Page Resources Overview

Click here for further information

MSDN, Microsoft

You create a Web application by using Microsoft ASP.NET 3.5. You add the following

markup to a page:

<asp:TextBox ID="numberTextBox" runat="server"/>

Page 103: 70562 (1)

<asp:RequiredFieldValidator ID="requiredValidator" runat="server" ErrorMessage="You

must specify a number." ControlToValidate="numberTextBox"/>

<asp:CompareValidator ID="numberValidator" runat="server"

Operator="DataTypeCheck" Type="Double" ErrorMessage="The value must be a

number." ControlToValidate="numberTextBox"/>

<asp:CustomValidator ID="precisionValidator" runat="server"

ServerValidate="ValidatePrecision" ErrorMessage="The number must contain three

decimal digits or less." ControlToValidate="numberTextBox"/>

Values entered into the numberTextBox control must be numbers that contain three

decimal places or less.

You need to implement the ValidatePrecision event handler to meet this requirement.

Which code segment should you use?

protected void ValidatePrecision(object sender, ServerValidateEventArgs e)

{

string[] decimalSides = e.Value.TrimEnd('0').Split('.');

int decimalPrecision = 0;

if (decimalSides.Length == 2)

{

decimalPrecision = decimalSides[1].Length;

}

if (decimalPrecision <= 3)

{

e.IsValid = true;

}

}

protected void ValidatePrecision(object sender, ServerValidateEventArgs e)

{

string[] decimalSides = e.Value.TrimEnd('0').Split('.');

int decimalPrecision = 0;

if (decimalSides.Length == 2)

{

decimalPrecision = decimalSides[1].Length;

}

if (decimalPrecision <= 3)

Page 104: 70562 (1)

{

Page.IsValid = true;

}

}

protected void ValidatePrecision(object sender, ServerValidateEventArgs e)

{

string[] decimalSides = e.Value.TrimEnd('0').Split('.');

int decimalPrecision = 0;

if (decimalSides.Length == 2)

{

decimalPrecision = decimalSides[1].Length;

}

e.IsValid = decimalPrecision <= 3;

}

protected void ValidatePrecision(object sender, ServerValidateEventArgs e)

{

if (e.Value <= 3)

{

Page.IsValid = e.IsValid;

}

}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#)

(Preview)

Question ID: jehMS_70-562CS-011 Jump to Question ID

Question 40 Explanation:

You should set the IsValid property of the ServerValidateEventArgs instance to true if the value of

the Value property contains three decimal places or less. Otherwise, you should set the IsValid

property to false. By default, the property is set to true. The Value property specifies the string

Page 105: 70562 (1)

representation of the value being validated.

You should not set the IsValid property of the Page instance to the value of the IsValid property of

the ServerValidateEventArgs instance. By default, the IsValid property of the

ServerValidateEventArgs instance is true.

You must set the IsValid property of the ServerValidateEventArgs instance to false if the value of

the Value property contains more than three decimal places. Otherwise, validation will always

succeed. This is because the default value of the IsValid property is true.

Objective:

List all questions for this objective

</P< td> Consuming and Creating Server

Controls

Sub-Objective:

2.4 Implement client-side validation and server-side validation.

References:

1. How to: Validate with a Custom Function for ASP.NET Server Controls

Page 106: 70562 (1)

Click here for further information

MSDN, Microsoft

Question 41 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following code is defined in a the code-behind file for a user control named Header.ascx, which exists in the root application directory:

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

You need to programmatically load the Header user control and set the Message property to the string Welcome.

Which code segment should you use?

UserControl control = new UserControl();control.LoadControl("~/Header.ascx");Header header = control as Header;if (header != null){header.Message = "Welcome";}

Header header = (Header)LoadControl("~/Header.ascx");header.Message = "Welcome";

Header header = new Header();

Page 107: 70562 (1)

header.LoadControl("~/Header.ascx");header.Message = "Welcome";

PartialCachingControl control = (PartialCachingControl) LoadControl("~/Header.ascx");Header header = control.CachedControl as Header;if (header != null){header.Message = "Welcome";}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-026 Jump to Question ID

Question 41 Explanation:

You should call the LoadControl method of the Page class, passing to it the virtual path

to the Header user control. In this scenario, the PartialCaching attribute is applied to

the Header class, which indicates that the user control is configured for output caching

for 20 seconds. Because the PartialCaching attribute is applied to the Header class, the

LoadControl method returns a PartialCachingControl instance that represents a cached

representation of the user control. To obtain an instance of the true Header control, you

must access the CachedControl property of the PartialCachingControl class. If this

property returns a null value, then the Header control is cached and cannot be

accessed. Therefore, you must check for a null value before setting the Message

property of the Header class.

You should not call the UserControl constructor. To load the Header user control, you

must call the LoadControl method of the Page class.

You should not cast the instance returned from the LoadControl method to Header.

Because the PartialCaching attribute is applied to the Header class, this method returns

a PartialCachingControl instance that represents a cached representation of the user

control. To obtain an instance of the true Header control, you must access the

CachedControl property of the PartialCachingControl class. If the Header user control

were not configured for output caching, the LoadControl method would return an

instance of the Header class.

You should not call the Header constructor. To load the Header user control, you must

call the LoadControl method of the Page class.

Page 108: 70562 (1)

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.2 Load user controls dynamically.

References:

1. How to: Create Instances of ASP.NET User Controls Programmatically

Click here for further information

MSDN, Microsoft

2. TemplateControl.LoadControl Method (String)

Click here for further information

MSDN, Microsoft

3. Caching Portions of an ASP.NET Page

Click here for further information

MSDN, Microsoft

Question 42 / 75 Mark for Review

You create a Web site by using Microsoft ASP.NET 3.5.

You need to generate a single assembly for the entire Web site. Your solution must generate dummy markup pages.

What should you do?

Page 109: 70562 (1)

Run the ASP.NET Compiler Tool (Aspnet_compiler.exe) without the -u option. Run the ASP.NET Merge Tool (Aspnet_merge.exe) with the -o option.

Run the ASP.NET Registration Tool (Aspnet_regiis.exe) without the -u option. Run the ASP.NET Merge Tool (Aspnet_merge.exe) with the -o option.

Run the ASP.NET Compiler Tool (Aspnet_compiler.exe) without the -u option. Run the ASP.NET Registration Tool (Aspnet_regiis.exe) without the -u option.

Run the ASP.NET Merge Tool (Aspnet_merge.exe) with the -o option. Run the ASP.NET Browser Registration Tool (Aspnet_regbrowsers.exe) with the -u option.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-057 Jump to Question ID

Question 42 Explanation:

You should run Aspnet_compiler.exe without the -u option. This compiles the Web site

into files that cannot be updated after deployment. For example, markup files such as

declarative pages do not contain any content. They only serve as placeholders so that

users can browse to them. Actual instances of the pages are created from compiled

code.

You should also run Aspnet_merge.exe with the -o option. This creates a single

assembly for the entire Web site. It also modifies all files that have the .compiled file

extension to reference a single assembly.

You should not run Aspnet_regiis.exe. This tool allows you to install ASP.NET and update

script maps for applications. Script maps associate applications with specific ASP.NET

versions.

You should not run Aspnet_regbrowsers.exe. This tool creates an assembly from the

browser definitions in the .NET Framework Browsers directory.

Page 110: 70562 (1)

Objective:

List all questions for this objective</P< td>

Configuring and Deploying Web

Applications

Sub-Objective:

1.7 Compile an application by using Visual Studio or command-line tools.

References:

1. Managing ASP.NET Precompiled Output for Deployment Using the aspnet_merge.exe Command

Click here for further information

MSDN, Microsoft

2. ASP.NET Compilation Tool (Aspnet_compiler.exe)

Click here for further information

MSDN, Microsoft

3. ASP.NET Web Site Precompilation Overview

Click here for further information

MSDN, Microsoft

4. How to: Precompile ASP.NET Web Sites for Deployment

Click here for further information

MSDN, Microsoft

5. ASP.NET IIS Registration Tool (Aspnet_regiis.exe)

Click here for further information

MSDN, Microsoft

Page 111: 70562 (1)

Question 43 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You add the following markup 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 derives from WebControl. It does not implement any interfaces. Only the following attributes are applied to the control's class: ToolboxData, Designer, and DefaultProperty.

You need to ensure that the Question control can participate in server-side validation on this page.

What should you do?

Modify the Question control's class to implement IValidator.

Set the ValidationGroup property of the RequiredFieldValidator control to UserControl.

Apply the ValidationProperty attribute to the Question control's class.

Set the InitialValue property of the RequiredFieldValidator control to an empty string.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-042 Jump to Question ID

Question 43 Explanation:

You should apply the ValidationProperty attribute to the Question control's class. Only

server controls marked with the ValidationProperty attribute can participate in server-

side validation by using validation controls. When the RequiredFieldValidator control is

used, it checks the parameter to the ValidationProperty attribute of the control being

Page 112: 70562 (1)

validated. The parameter to this attribute should specify the property of the control to

be validated. If the value of the property is set to the same value as the InitialValue

property of the RequiredFieldValidator control, validation fails. Otherwise, validation

succeeds.

You should not modify the Question control's class to implement IValidator. Only

validation controls should implement this interface.

You should not set the InitialValue property of the RequiredFieldValidator control to an

empty string. If you do not set this property, it automatically defaults to an empty

string.

You should not set the ValidationGroup property of the RequiredFieldValidator control to

UserControl. The ValidationGroup property allows you to specify the group to which a

validation control or a control that causes validation belongs. When a control causes

validation, only the validation controls that belong to the same group are validated.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.4 Implement client-side validation and server-side validation.

References:

1. ValidationPropertyAttribute Class

Click here for further information

MSDN, Microsoft

2. ASP.NET Validation in Depth

Click here for further information

MSDN, Microsoft

3. How to: Validate Required Entries for ASP.NET Server Controls

Page 113: 70562 (1)

Click here for further information

MSDN, Microsoft

Question 44 / 75 Mark for Review

You create a custom control that will be consumed by a Microsoft ASP.NET 3.5 application. The following code exists in a JavaScript file named Expand.js:

function OnHeaderClicked(contentDivID) { var img = event.srcElement; var contentDiv = window.document.getElementById(contentDivID); if (contentDiv.style.display == "none") { img.src = "<%= WebResource(ImageUp.gif)%>"; contentDiv.style.display = "block"; } else { img.src = "<%= WebResource(ImageDown.gif)%>"; contentDiv.style.display = "none"; } }

You configure the JavaScript file as an embedded resource in a project folder named Scripts. The default namespace of the project is BcdTrain.

You need to configure the script as a Web resource.

Which code segment should you use?

[assembly:WebResource("Expand.js", "text/javascript")]

[assembly:WebResource("BcdTrain.Scripts.Expand.js", "text/javascript", PerformSubstitution=true)]

[assembly:WebResource("BcdTrain.Expand.js", "text/javascript", PerformSubstitution=false)]

[assembly:WebResource("Scripts.Expand.js", "text/javascript")]

Page 114: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-022 Jump to Question ID

Question 44 Explanation:

You should specify BcdTrain.Scripts.Expand.js as the first parameter to the

WebResource attribute. This parameter specifies the fully-qualified resource name,

which is equal to the default namespace of the project plus any subfolders that contain

the resource, followed by the resource name itself, all separated by periods. In this

scenario, the default namespace is BcdTrain, the resource is contained in a folder

named Scripts, and the resource name is Expand.js. A Web resource is one that can be

accessed over Hypertext Transfer Protocol (HTTP) via the WebResource.axd HTTP

handler. The second parameter is the content type of the resource. Because the

JavaScript file contains other embedded references to Web resources, as identified by

the <%= WebResource(Resource) %> syntax, you should set the PerformSubstitution

property of the WebResource attribute to true. This causes the embedded Web resource

image references to be replaced with the appropriate WebResource.axd URLs when the

Expand.js Web resource is processed.

You should not specify any other name as the first parameter to the WebResource

attribute. You must specify the fully-qualified name of the resource, which is equal to

the default namespace of the project plus any subfolders that contains the resource,

followed by the resource name itself, all separated by periods.

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.4 Create and register client script.

References:

1. WebResourceAttribute Class

Click here for further information

Page 115: 70562 (1)

MSDN, Microsoft

2. WebResourceAttribute.PerformSubstitution Property

Click here for further information

MSDN, Microsoft

Question 45 / 75 Mark for Review

You create a mobile Web application by using Microsoft ASP.NET 3.5. The following code exists in an assembly named MobileClient:

namespace BcdTrain.MobileClient { public class Capabilities { public static bool IsEnhancedDevice(MobileCapabilities capabilities, string optional) { return (capabilities["AJAX"] == Boolean.TrueString && capabilities["Silverlight"] == Boolean.TrueString); } } }

A page in the Web application contains the following code:

MobileCapabilities capabilities = (MobileCapabilities)Request.Browser; bool isEnhancedDevice = capabilities.HasCapability("SilverlightAndAjax", null)

You need to configure the Web.config file to ensure that this code calls the IsEnhancedDevice method of the Capabilities class.

Which configuration should you use?

<mobileControls><device name="SilverlightAndAjax" predicateClass="BcdTrain.MobileClient.Capabilities, MobileClient" predicateMethod="IsEnhancedDevice"/>

Page 116: 70562 (1)

</mobileControls>

<clientTarget><add userAgent="SilverlightAndAjax"alias="BcdTrain.MobileClient.Capabilities.IsEnhancedDevice, MobileClient"</clientTarget>

<browserCaps><filter match="SilverlightAndAjax"/><result type="BcdTrain.MobileClient.Capabilities, MobileClient"/><use as="IsEnhancedDevice"/></browserCaps>

<deviceFilters><filter name="SilverlightAndAjax" type="BcdTrain.MobileClient.Capabilities, MobileClient"method="IsEnhancedDevice"/></deviceFilters>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-039 Jump to Question ID

Question 45 Explanation:

You should define a filter in the deviceFilters section of the Web.config file. The

HasCapability method first checks the deviceFilters section to determine whether a filter

exists that has the same name as the first parameter to the method. If so, that filter is

evaluated. If not, the method determines whether the MobileCapabilities instance has a

property that has the same name as the first parameter. If so, it evaluates that

property. If not, the method determines whether the dictionary exposed by the

MobileCapabilties instance has a key that has the same name as the first parameter. If

so, it evaluates the item associated with that key. By defining a device filter that has

the same name as the first parameter of the HasCapability method, you can allow that

filter to perform the evaluation. When you specify type and method attributes in the

filter element, the HasCapability method calls a method to perform the filter evaluation.

The type attribute specifies the fully-qualified type name of the class that contains the

evaluator method. The method attribute specifies the name of the method to call.

You should not define a device in the mobileControls section of the Web.config file. This

section allows you to configure adaptive rendering. Adaptive rendering allows you to

change the behavior or rendering functionality of a control based on the browser's

device.

You should not specify the browserCaps section in the Web.config file. This section

Page 117: 70562 (1)

allows you to define browser definitions for an application. Although this mechanism is

supported, it is deprecated. You should add browser files to the App_Browsers folder to

define browser definitions for an application.

You should not specify the clientTarget section in the Web.config file. This section allows

you to define aliases for browser user agents.

Objective:

List all questions for this objective</P< td>

Targeting Mobile Devices

Sub-Objective:

6.1 Access device capabilities.

References:

1. Evaluating Capabilities Programmatically

Click here for further information

MSDN, Microsoft

2. Device Evaluation Methods

Click here for further information

MSDN, Microsoft

Question 46 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You create a folder named Classic in the App_Themes folder of the Web application. You add four skin files to this folder.

Page 118: 70562 (1)

You need to ensure that all controls on a page have their appearances overridden by the control definitions defined in the skin files.

Which Page directive should you use?

<%@ Page StyleSheetTheme="App_Themes.Classic"/>

<%@ Page Theme="App_Themes.Classic"/>

<%@ Page Theme="Classic"/>

<%@ Page StyleSheetTheme="Classic"/>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-070 Jump to Question ID

Question 46 Explanation:

You should set the Theme attribute of the Page directive to Classic. Page themes are

represented by subfolders of the App_Themes folder. The Theme attribute specifies the

theme to use to override control appearances on a page.

You should not set the Theme attribute to App_Themes.Classic. You must set the value

of this attribute to a subfolder of the App_Themes folder.

You should not set the StyleSheetTheme attribute. This attribute specifies a theme that

can be overridden by controls on a page. In this scenario, you need the theme to

override the appearances of controls.

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

Page 119: 70562 (1)

7.1 Customize the layout and appearance of a Web page.

References:

1. ASP.NET Themes and Skins Overview

Click here for further information

MSDN, Microsoft

Question 47 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You deploy the application to a test server and enable debugging. The application is hosted in Microsoft Internet Information Services (IIS) 6.0. Its application pool uses the Network Service identity.

You need to configure the environment to allow you to debug the application from your development computer.

What should you do? (Each correct answer presents part of the solution. Choose two.)

Install the remote debugging components on the test server.

Set the mode attribute of the customErrors element to Off in the Web.config file.

Create a Debugger Users group on your computer and add your account to it.

Clear the Disable script debugging (Other) option in Internet Explorer on the test server.

Ensure that you have administrative privileges on the test server.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-045 Jump to Question ID

Page 120: 70562 (1)

Question 47 Explanation:

You should ensure that you have administrative privileges on the test server.

Administrative privileges allow you to debug a process that runs under a different

identity.

You should also install the remote debugging components on the test server. These

components allow you to attach a debugger to the application.

You should not create a Debugger Users group on your computer and add your account

to it. Previous versions of Visual Studio and ASP.NET required users to be members of

the Debugger Users group on the remote computer to debug a remote process. In this

scenario, the remote computer is the test server. Microsoft Visual Studio 2008 and

ASP.NET 3.5 do not require users to be members of the Debugger Users group.

You should not clear the Disable script debugging (Other) option in Internet Explorer on

the test server. This option determines whether script debugging client script in

browsers other than Internet Explorer is enabled. To debug client script in a browser

other than Internet Explorer, you must clear this option on the client computer, not the

remote computer.

You should not set the mode attribute of the customErrors element to Off in the

Web.config file. This attribute determines whether or not the details of unhandled

exceptions will be automatically displayed to the user.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.2 Set up an environment to perform remote debugging.

References:

1. How to: Set Up Remote Debugging

Click here for further information

Page 122: 70562 (1)

You create a Web site by using Microsoft ASP.NET 3.5. You create a compact HTML (cHtml) text writer class named BlackPhoneChtmlTextWriter for rendering to a specific device. The class exists in the App_Code folder.

You need to ensure that all Calendar server controls use this text writer when rendering to that

Page 123: 70562 (1)

Question 49 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You add a JavaScript script file named CustomScripts.js as an embedded resource. The file exists in a project subfolder named Scripts. The name of the application's assembly is BcdTrain, and the default namespace of the application is BcdTrain.Web.

You need to use the ScriptManager control to register the script for use in the Web application.

Which declaration should you use?

<asp:ScriptManager ID="_scriptManager" runat="server"><Scripts><asp:ScriptReference Assembly="BcdTrain.dll" Name="Scripts.CustomScripts.js"/><Scripts></asp:ScriptManager>

<asp:ScriptManager ID="_scriptManager" runat="server"><Scripts><asp:ScriptReference Assembly="BcdTrain" Name="BcdTrain.Web.Scripts.CustomScripts.js"/><Scripts></asp:ScriptManager>

<asp:ScriptManager ID="_scriptManager" runat="server"><Scripts><asp:ScriptReference Assembly="BcdTrain" Name="BcdTrain.Web.CustomScripts.js"/><Scripts></asp:ScriptManager>

<asp:ScriptManager ID="_scriptManager" runat="server"><Scripts><asp:ScriptReference Assembly="BcdTrain.dll" Name="CustomScripts.js"/><Scripts></asp:ScriptManager>

Page 124: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-069 Jump to Question ID

Question 49 Explanation:

You should use the following declaration:

<asp:ScriptManager ID="_scriptManager" runat="server">

<Scripts>

<asp:ScriptReference

Assembly="BcdTrain"

Name="BcdTrain.Web.Scripts.CustomScripts.js"/>

<Scripts>

</asp:ScriptManager>

This markup defines a script reference that references the CustomScripts.js embedded

resource in the BcdTrain assembly. The Assembly property of the ScriptReference class

specifies the assembly that contains the embedded resource. The Name property

specifies the fully-qualified name of the embedded resource, which is equal to the

default namespace of the project plus any subfolders that contains the resource,

followed by the resource name itself, all separated by periods. In this scenario, the

default namespace is BcdTrain.Web, the resource is contained in a folder named Scripts,

and the resource name is CustomScripts.js.

You should not use the following declaration:

<asp:ScriptManager ID="_scriptManager" runat="server">

<Scripts>

<asp:ScriptReference

Assembly="BcdTrain.dll"

Name="CustomScripts.js"/>

<Scripts>

</asp:ScriptManager>

This markup sets the Assembly property to BcdTrain.dll and the Name property to

CustomScripts.js. You must set the Assembly property to the name of the assembly

without the file extension. You must set the Name property to the fully-qualified name

of the embedded resource.

You should not use the following declaration:

Page 125: 70562 (1)

<asp:ScriptManager ID="_scriptManager" runat="server">

<Scripts>

<asp:ScriptReference

Assembly="BcdTrain"

Name="BcdTrain.Web.CustomScripts.js"/>

<Scripts>

</asp:ScriptManager>

You must set the Name property to the fully-qualified name of the embedded resource.

You should not use the following declaration:

<asp:ScriptManager ID="_scriptManager" runat="server">

<Scripts>

<asp:ScriptReference

Assembly="BcdTrain.dll"

Name="Scripts.CustomScripts.js"/>

<Scripts>

</asp:ScriptManager>

You must set the Assembly property to the name of the assembly without the file

extension. You must set the Name property to the fully-qualified name of the embedded

resource.

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.4 Create and register client script.

References:

1. ScriptReference Class

Click here for further information

Page 126: 70562 (1)

MSDN, Microsoft

2. Walkthrough: Embedding a JavaScript File as a Resource in an Assembly

Click here for further information

MSDN, Microsoft

Question 50 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. A third-party assembly contains custom server controls. This assembly is not part of your application's Microsoft Visual Studio 2008 solution, and it does not have a strong name.

You need to configure your application's project so that it can use the custom controls.

What should you do?

Add a project reference to the project.

Add a Web reference to the project.

Add a service reference to the project.

Add an assembly reference to the project.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-054 Jump to Question ID

Question 50 Explanation:

You should add an assembly reference to the project. This adds the assembly to the Bin

Page 127: 70562 (1)

folder of the application, which allows you to use the custom controls in your

application. Because the assembly containing the custom controls does not have a

strong name, you cannot add it to the global assembly cache (GAC). Therefore, you

must add it to your application's Bin folder to use it.

You should not add a project reference to the project. To add a project reference, a

project containing the custom controls must exist in the same solution.

You should not add a Web reference to the project. A Web reference allows you to

create proxy classes for Web services.

You should not add a service reference to the project. A service reference allows you to

create proxy classes for Windows Communication Foundation (WCF) services.

Objective:

List all questions for this objective</P< td>

Configuring and Deploying Web

Applications

Sub-Objective:

1.3 Configure projects, solutions, and reference assemblies.

References:

1. Managing References

Click here for further information

MSDN, Microsoft

Question 51 / 75 Mark for Review

Page 128: 70562 (1)

You create a Web application by using Microsoft ASP.NET 3.5. The following class exists in the application:

public class Exam { public string Title {get; set;} public string Number { get; set; } public string Vendor { get; set; } }

You create an instance of List<Exam> named examList. You create a DropDownList control named examDropDownList. You must bind examDropDownList to the examList instance and display the Title property of each Exam instance.

You need to write code to bind the examDropDownList control to the examList instance.

Which code segment should you use?

examDropDownList.DataSource = examList;examDropDownList.DataValueField = "Exam.Title";examDropDownList.DataBind();

examDropDownList.DataSource = examList;examDropDownList.DataTextField = "Title";examDropDownList.DataBind();

examDropDownList.DataSource = examList;examDropDownList.DataMember = "Title";examDropDownList.DataBind();

examDropDownList.DataSourceID = "examList";examDropDownList.DataTextFormatString = "Exam.Title";examDropDownList.DataBind();

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-008 Jump to Question ID

Question 51 Explanation:

You should set the DataSource property of examDropDownList to the examList instance,

and you should set the DataTextField property of examDropDownList to the string Title.

The DataSource property specifies the data source to which the control is being bound.

The DataTextField property specifies the display member of an item of the data source

being bound. In this scenario, each item of the data source is an Exam instance. The

Page 129: 70562 (1)

Title property is the member of that item that should be displayed.

You should not set the DataMember property of examDropDownList. The DataMember

property specifies the data to be bound in a multimember data source, such as a

DataSet instance. For example, a DataSet instance might contain multiple DataTable

instances. If you set the DataSource property of a DropDownList control to a DataSet

instance, you must set the DataMember property to the name of the DataTable instance

to be bound. A multimember data source is typically one that implements IListSource.

You should not set the DataValueField property of examDropDownList. The

DataValueField property specifies the value member of an item of the data source being

bound.

You should not set the DataSourceID property or the DataTextFormatString property of

examDropDownList. The DataSourceID property specifies the ID of a data source

control. The DataTextFormatString property specifies a format string for displaying

items in a DropDownList control.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.1 Implement data-bound controls.

References:

1. ListControl.DataTextField Property

Click here for further information

MSDN, Microsoft

2. DropDownList Class

Click here for further information

MSDN, Microsoft

Page 130: 70562 (1)

Question 52 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following markup exists on a page:

<asp:TextBox ID="_nameTextBox" runat="server"/> <asp:RequiredFieldValidator ID="_nameRequiredValidator" runat="server" ControlToValidate="_nameTextBox" ErrorMessage="Name is required." ValidationGroup="Name"/> <asp:TextBox ID="_cardTextBox" runat="server"/> <asp:RequiredFieldValidator ID="_cardRequiredValidator" runat="server" ControlToValidate="_cardTextBox" ErrorMessage="Card number is required." ValidationGroup="Card"/> <asp:RangeValidator ID="_cardRangeValidator" runat="server" MinimumValue="11111" MaximumValue="99999" ControlToValidate="_cardTextBox" ErrorMessage="Card number is invalid." ValidationGroup="Card"/>

You need to validate the _cardTextBox control and call a method named Process if validation succeeds.

Which code segment should you use?

Context["ValidationGroup"] = "Card";Page.Validate();if (Page.IsValid){Process();}

Context["ValidationGroup"] = "Card";Page.Validate();bool isValid = true;foreach (IValidator validator in Page.Validators){if (!validator.IsValid){isValid = false;break;}}if (isValid){Process();}

Page 131: 70562 (1)

Page.Validate("Card");if (Page.IsValid){Process();}

Page.Validate("Card");bool isValid = true;foreach (IValidator validator in Page.Validators){if (!validator.IsValid){isValid = false;break;}}if (isValid){Process();}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-028 Jump to Question ID

Question 52 Explanation:

You should call the Validate method of the Page class, passing to it the validation group

to validate. In this scenario, to validate the _cardTextBox control, you must validate all

validation controls associated with it. Two validation controls exist: a

RequiredFieldValidator control and a RangeValidator control. Both controls are assigned

to a validation group named Card. Therefore, you should pass the value Card as a

parameter to the Validate method. This causes only those two controls to perform

validation. If validation succeeds, the IsValid property of the Page class is set to true.

Otherwise, it is set to false. You should call the Process method only if the IsValid

property is set to true.

You should not call the Validate method that takes no parameters. This method causes

all validation controls to perform validation. This means that if the _nameTextBox

control fails validation but the _cardTextBox control passes validation, the IsValid

property of the Page class will still be set to false.

You should not loop through all validators contained in the Validators collection of the

Page class and call the Process method only if they all passed validation. You should call

the Process method only if the validation controls associated with the _cardTextBox

control pass validation. Validators in the Validators collection are instances of IValidator.

Page 132: 70562 (1)

This interface defines an IsValid property that indicates whether or not validation is

successful.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.4 Implement client-side validation and server-side validation.

References:

1. How to: Validate Programmatically for ASP.NET Server Controls

Click here for further information

MSDN, Microsoft

2. How to: Test Validity Programmatically for ASP.NET Server Controls

Click here for further information

MSDN, Microsoft

3. Specifying Validation Groups

Click here for further information

MSDN, Microsoft

Question 53 / 75 Mark for Review

Page 133: 70562 (1)

You create a Web application by using Microsoft ASP.NET 3.5. The following configuration exists in the Web.config file:

<authorization> <deny users="?"/> </authorization> <authentication mode="Forms"/> <identity impersonate="false"/>

The application is hosted in Microsoft Internet Information Services (IIS) 6.0. In IIS, integrated Windows authentication is enabled, and anonymous access is disabled. The application pool is configured to run as the identity BcdTrain\WebApp. The IIS anonymous account is BcdTrain\Anonymous.

The following code exists in the code-behind file for a page:

string name = WindowsIdentity.GetCurrent().Name; Response.Write(name);

A user whose domain user account is BcdTrain\User1 accesses the page. That user logs in to the Web application with the user name FormsUser.

You need to identify the output of this code when the user accesses the page.

What would be the output of this code?

FormsUser

BcdTrain\User1

BcdTrain\Anonymous

BcdTrain\WebApp

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-033 Jump to Question ID

Question 53 Explanation:

The output of the code would be BcdTrain\WebApp. When impersonation is disabled for

a Web application, the application runs under the identity that is configured for the

application pool. In this scenario, this identity is BcdTrain\WebApp. The GetCurrent

method of the WindowsIdentity class returns a WindowsIdentity instance that

represents the identity associated with the current thread. The Name property of the

WindowsIdentity class returns the name of the identity.

Page 134: 70562 (1)

The output of the code would not be BcdTrain\User1. This would occur if impersonation

were enabled. When impersonation is enabled, the application runs under the identity

of the authenticated user unless anonymous access is enabled. If anonymous access is

enabled, the application runs under the identity of the anonymous account.

The output of the code would not be BcdTrain\Anonymous. This would occur only if

impersonation and anonymous access were enabled.

The output of the code would not be FormsUser. Forms authentication identities are not

returned by the GetCurrent method of the WindowsIdentity class.

Objective:

List all questions for this objective</P< td>

Configuring and Deploying Web

Applications

Sub-Objective:

1.2 Configure authentication, authorization, and impersonation.

References:

1. ASP.NET Impersonation

Click here for further information

MSDN, Microsoft

2. ASP.NET Impersonation

Click here for further information

MSDN, Microsoft

3. ASP.NET Impersonation

Click here for further information

MSDN, Microsoft

4. ASP.NET Security Architecture

Click here for further information

Page 135: 70562 (1)

MSDN, Microsoft

Question 54 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5.

You need to configure the Web.config file to enable debugging for all pages in the application.

Which configuration should you use?

<compilation debug="true"/>

<pages configSource="debug"/>

<appSettings><add key="compilation" value="debug"/></appSettings>

<system.diagnostics><switches><add name="debug" value="true"/></switches></system.diagnostics>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-044 Jump to Question ID

Question 54 Explanation:

You should set the debug attribute of the compilation element to true. This causes the

compiler to add DEBUG symbols to the generated assembly. This allows you to attach a

debugger to the assembly and step through the code.

You should not add a trace switch to the switches element. Trace switches allow you to

Page 136: 70562 (1)

write conditional diagnostic trace messages in an application based on the value of the

switch.

You should not set the configSource attribute of the pages element to debug. The

configSource attribute specifies a configuration file in which the associated configuration

element is defined.

You should not add an application setting to the appSettings element. This element

defines custom key-value pairs that are specific to an application.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.1 Configure debugging and custom errors.

References:

1. customErrors Element (ASP.NET Settings Schema)

Click here for further information

MSDN, Microsoft

2. Rich Custom Error Handling with ASP.NET

Click here for further information

MSDN, Microsoft

Page 137: 70562 (1)

Question 55 / 75 Mark for Review

You create a mobile Web application by using Microsoft ASP.NET 3.5. You need to add a PhoneCall control to the page that must meet the following requirements:

* The following text is rendered by the control on all devices that support phone calls: Call Support * The following text is rendered by the control on all other devices: Call Support at 1-800-649-1687 * On Palm devices, the phone number dialed must be 8006491687. * On all other devices, the phone number dialed must be (800) 649-1687.

You need to declare the PhoneCall control.

Which declaration should you use?

<mobile:PhoneCall ID="phoneCall" runat="server" PhoneNumber="(800) 649-1687"myPalm:PhoneNumber="8006491687"AlternateFormat="{0} at 1-800-649-1687">Call Support</mobile:PhoneCall>

<mobile:PhoneCall ID="phoneCall" runat="server"PhoneNumber="(800) 649-1687"AlternateFormat="{0} at {1}"><DeviceSpecific><Choice Filter="myPalm" PhoneNumber="8006491687"/></DeviceSpecific>Call Support</mobile:PhoneCall>

<mobile:PhoneCall ID="phoneCall" runat="server"PhoneNumber="(800) 649-1687"myPalm:PhoneNumber="8006491687"AlternateFormat="{0} at {1}">Call Support</mobile:PhoneCall>

<mobile:PhoneCall ID="phoneCall" runat="server"AlternateFormat="{0} at {1}"><DeviceSpecific><Choice Filter="*" PhoneNumber="(800) 649-1687"/><Choice Filter="myPalm" PhoneNumber="8006491687"/></DeviceSpecific>Call Support</mobile:PhoneCall>

Page 138: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-052 Jump to Question ID

Question 55 Explanation:

You should use the following declaration:

<mobile:PhoneCall ID="phoneCall" runat="server"

PhoneNumber="(800) 649-1687"

myPalm:PhoneNumber="8006491687"

AlternateFormat="{0} at 1-800-649-1687">Call Support

</mobile:PhoneCall>

The declaration specifies two different PhoneNumber properties: one with a prefix and

one without a prefix. This special type of device filtering, known as browser filtering,

allows different browsers to render different content for properties, attributes, and

templates. To use browser filtering, you should prefix each property or attribute that

must be rendered differently with the ID of a specific browser. By default, the ID for

Palm browsers is myPalm. Therefore, the value you specify for the

myPalm:PhoneNumber property will be used when the browser requesting the page is a

Palm device. If no prefix is assigned to a property, that property specifies the default

value. This means that all other devices will use the value assigned to the

PhoneNumber property that does not specify a prefix. This declaration also sets the

AlternateFormat property. This property specifies the format to use for devices that do

not support phone calls. Any occurrences of the {0} placeholder are replaced with the

value of the Text property. Any occurrences of the {1} placeholder are replaced with

the value of the PhoneNumber property.

You should not use the following declaration:

<mobile:PhoneCall ID="phoneCall" runat="server"

PhoneNumber="(800) 649-1687"

AlternateFormat="{0} at {1}">

<DeviceSpecific>

<Choice Filter="myPalm" PhoneNumber="8006491687"/>

</DeviceSpecific>

Call Support

</mobile:PhoneCall>

Page 139: 70562 (1)

The AlternateFormat property would cause the PhoneNumber control to render the

following text on devices that do not support phone calls: Call Support at (800)

649-1687. Also, to use a DeviceSpecific control to accomplish your goal, you would

need to ensure that a device filter named myPalm is defined in the Web.config file.

You should not use the following declaration:

<mobile:PhoneCall ID="phoneCall" runat="server"

PhoneNumber="(800) 649-1687"

myPalm:PhoneNumber="8006491687"

AlternateFormat="{0} at {1}">Call Support

</mobile:PhoneCall>

The AlternateFormat property would cause the PhoneNumber control to render the

following text on devices that do not support phone calls: Call Support at (800)

649-1687.

You should not use the following declaration:

<mobile:PhoneCall ID="phoneCall" runat="server"

AlternateFormat="{0} at {1}">

<DeviceSpecific>

<Choice Filter="*" PhoneNumber="(800) 649-1687"/>

<Choice Filter="myPalm" PhoneNumber="8006491687"/>

</DeviceSpecific>

Call Support

</mobile:PhoneCall>

Although you can use DeviceSpecific controls to accomplish your goal, you should not

set the Filter attribute of a Choice element to *. To allow a Choice element to be the

default content renderer, you should not specify a Filter attribute. Also, you would need

to ensure that a device filter named myPalm is defined in the Web.config file. Also, the

AlternateFormat property would cause the PhoneNumber control to render the following

text on devices that do not support phone calls: Call Support at (800) 649-1687.

Page 140: 70562 (1)

Objective:

List all questions for this objective</P< td>

Targeting Mobile Devices

Sub-Objective:

6.3 Add mobile Web controls to a Web page.

References:

1. ASP.NET Device Filtering Overview

Click here for further information

MSDN, Microsoft

2. PhoneCall Control

Click here for further information

MSDN, Microsoft

Question 56 / 75 Mark for Review

You create a custom control that will be consumed by a Microsoft ASP.NET 3.5 application. The control is implemented in a separate assembly. The default namespace of the assembly is BcdTrain. You add a JavaScript file named Validation.js to a project folder named Scripts and configure the image as an embedded resource.

You need to programmatically reference the script on the containing page when the page is rendered.

What should you do? (Each correct answer presents part of the solution. Choose two.)

Page 141: 70562 (1)

Add the following attribute to the AssemblyInfo.cs file:[assembly:WebResource("BcdTrain.Scripts.Validation.js", "text/javascript")]

Override the OnLoad method of the control as follows:protected override void OnLoad(EventArgs e){Type type = this.GetType();string resource = "BcdTrain.Scripts.Validation.js";Page.ClientScript.GetWebResourceUrl(type, resource);base.OnLoad();}

Override the OnInit method of the control as follows:protected override void OnInit(EventArgs e){Type type = this.GetType();string resource = "BcdTrain.Scripts.Validation.js";Page.ClientScript.RegisterClientScriptResource(type, resource);base.OnInit();}

Override the OnPreInit method of the control as follows:protected override void OnPreInit(EventArgs e){Type type = this.GetType();string resource = "BcdTrain.Scripts.Validation.js";string script = Page.ClientScript.GetWebResourceUrl(type, resource);Page.ClientScript.RegisterClientScriptBlock(type, "JavaScript", script);base.OnPreInit();}

Add the following attribute to the AssemblyInfo.cs file:[assembly:WebResource("Validation.js", "text/javascript", PerformSubstitution=true)]

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-021 Jump to Question ID

Question 56 Explanation:

You should add the WebResource attribute to the AssemblyInfo.cs file to register the

Validation.js file as a Web resource. This means that it can be requested over Hypertext

Transfer Protocol (HTTP) via the WebResource.axd HTTP handler. The first parameter to

this attribute specifies the fully-qualified resource name, which is equal to the default

namespace of the project plus any subfolders that contain the resource, followed by the

resource name itself, all separated by periods. In this scenario, the default namespace

is BcdTrain, the resource is contained in a folder named Scripts, and the resource name

Page 142: 70562 (1)

is Validation.js.

You should override OnInit and call the RegisterClientScriptResource method of the

ClientScriptManager class, which is accessible via the ClientScript property of the Page

class. This method registers embedded client script resources, such as JavaScript files,

on the containing page.

You should not call the GetWebResourceUrl method of the ClientScriptManager class.

This method constructs the WebResource.axd request URL for retrieving the embedded

resource. It does not register client scripts on a page.

You should not call the RegisterClientScriptBlock method of the ClientScriptManager

class. You should use this method to register script code blocks, not script files

embedded as resources.

You should not specify Validation.js as the value of the first parameter to the

WebResource attribute. You must specify the fully-qualified resource name, which is

equal to the default namespace of the project plus any subfolders that contain the

resource, followed by the resource name itself, all separated by periods.

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.4 Create and register client script.

References:

1. WebResourceAttribute Class

Click here for further information

MSDN, Microsoft

2. ClientScriptManager.RegisterClientScriptResource Method

Click here for further information

MSDN, Microsoft

Page 143: 70562 (1)

3. ClientScriptManager.GetWebResourceUrl Method

Click here for further information

MSDN, Microsoft

Question 57 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You create a SqlDataAdapter instance named adapter that executes the following SQL command:

SELECT * FROM Customer; SELECT * FROM Product

You must to fill a DataSet instance from the two result sets. The first result set should be added to a table named Customer, and the second result set should be added to a table named Product.

You need to write code to accomplish your goal.

Which code segment should you use?

adapter.TableMappings.Add("Customers", "Customer");adapter.TableMappings.Add("Products", "Product");DataSet ds = new DataSet();adapter.Fill(ds);

DataSet ds = new DataSet();adapter.Fill(ds.Tables["Customer"]);adapter.Fill(ds.Tables["Product"]);

adapter.TableMappings.Add("Table", "Customer");adapter.TableMappings.Add("Table1", "Product");DataSet ds = new DataSet();adapter.Fill(ds);

adapter.MissingMappingAction = MissingMappingAction.Ignore;DataSet ds = new DataSet();adapter.Fill(ds, "Customer");adapter.Fill(ds, "Product");

Page 144: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-031 Jump to Question ID

Question 57 Explanation:

You should add table mappings to the SqlDataAdapter instance by calling the Add

method of the TableMappings collection. By default, the Fill method of the

SqlDataAdapter class creates a table for each result set returned by the SQL command.

The tables are named Table, Table1, Table2, etc. By providing table mappings, you can

dictate the names of the created tables. The first parameter of the Add method

specifies the result set table name, such as Table, Table1, Table2, etc. The second

parameter of the Add method specifies the user-friendly name.

You should not set the MissingMappingAction property of the SqlDataAdapter instance

to Ignore without adding table mappings. When the property is set to Ignore, any result

sets that are not mapped to tables in the DataSet instance are ignored. By default, the

property is set to Passthrough, which means that tables are created automatically when

no mapping exists.

You should not access the Tables property of the DataSet class to retrieve tables named

Customer and Product. For this to be successful, you must have already added tables

with these names to the DataSet instance.

You should not specify Customers or Products as the first parameter to the Add method

of the TableMappings collection. The result sets are given the names Table, Table1,

Table2, etc. Therefore, you must pass a result set name as the first parameter to the

method.

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.2 Manipulate data by using DataSet and DataReader objects.

References:

Page 145: 70562 (1)

1. Table Mapping in ADO.NET

Click here for further information

MSDN, Microsoft

2. Setting Up DataTable and DataColumn Mappings

Click here for further information

MSDN, Microsoft

3. MissingMappingAction Enumeration

Click here for further information

MSDN, Microsoft

4. DataAdapter.MissingMappingAction Property

Click here for further information

MSDN, Microsoft

Question 58 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You enable session state for the application.

You need to programmatically determine whether the session ID is maintained in the URL of the request.

What should you do?

Access the RequestType property of the HttpRequest class.

Access the IsCookieless property of the HttpSessionState class.

Call the UrlDecode method of the HttpServerUtility class.

Call the UrlEncode method of the HttpServerUtility clas.

Page 146: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-075 Jump to Question ID

Question 58 Explanation:

You should access the IsCookieless property of the HttpSessionState class. If this

property returns true, the session ID is maintained in the URL of the request. If it

returns false, the session ID is maintained in a session cookie.

You should not access the RequestType property of the HttpRequest class. This property

indicates whether the current request is a Hypertext Transfer Protocol (HTTP) GET or

POST request.

You should not call the UrlDecode method of the HttpServerUtility class. This method

decides the specified string that was previously encoded for HTTP transmission.

You should not call the UrlEncode method of the HttpServerUtility class. This method

encodes the specified string for HTTP transmission.

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.2 Work with ASP.NET intrinsic objects.

References:

1. HttpSessionState.IsCookieless Property

Click here for further information

MSDN, Microsoft

2. HttpRequest.RequestType Property

Click here for further information

MSDN, Microsoft

Page 147: 70562 (1)

3. HttpServerUtility.UrlDecode Method

Click here for further information

MSDN, Microsoft

4. HttpServerUtility.UrlEncode Method

Click here for further information

MSDN, Microsoft

Question 59 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The application is hosted in Microsoft Internet Information Services (IIS) 6.0. IIS uses the default configuration. The application accesses data from a Microsoft SQL Server 2008 database. The database administrator grants a custom domain account to the application for accessing the database. The application's Web.config file contains the following configuration:

<authentication mode="Forms"/> <identity impersonate="false"/>

You need to configure the application so that it can access the database successfully.

What should you do?

Change the isolation mode in IIS.

Change the identity associated with the application's application pool.

Modify the authentication element in the Web.config file as follows: <authentication mode="Windows"/>

Modify the identity element in the Web.config file as follows: <identity impersonate="true"/>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application

Page 148: 70562 (1)

Development (C#) (Preview) Question ID: jehMS_70-562CS-053 Jump to Question ID

Question 59 Explanation:

You should change the identity associated with the application's application pool to the

custom identity assigned by the database administrator. This identity is used to run the

worker process associated with that pool. Web applications run within a worker process.

By default, the identity assigned to an application pool is Network Service.

You should not set the mode attribute of the authentication element to Windows. The

authentication mode does not determine the identity under which the application runs.

It determines how the user is authenticated.

You should not change the impersonate attribute of the identity element to true. This

causes the application to run as the identity of the user authenticated in IIS. However,

the application must run as the identity that can access the database.

You should not change the isolation mode in IIS. The IIS isolation mode determines

how Web applications run. In the default mode, a worker process runs with the Network

Service identity. Web applications run within the worker process, and one worker

process is assigned to each application pool. In the IIS 5.0 mode, all Web applications

run within the IIS process.

Objective:

List all questions for this objective</P< td>

Configuring and Deploying Web

Applications

Sub-Objective:

1.6 Configure application pools.

References:

1. Working with Application Pools and Web Applications

Click here for further information

MSDN, Microsoft

Page 149: 70562 (1)

2. Configuring Isolation Modes (IIS 6.0)

Click here for further information

Microsoft TechNet, Microsoft

3. Identity Application Pool Settings

Click here for further information

MSDN, Microsoft

Question 60 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You add a ScriptManager control to a page to enable partial rendering. The following code exists in the code-behind file of the page:

protected void Page_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError(); Trace.Warn("Exception", "An unhandled exception has occurred.", ex); }

You enable ASP.NET tracing for the page. When you visit the page for the first time, you can view the trace message in the page output if an unhandled exception occurs. However, you cannot view the trace message in the page output if an unhandled exception occurs during an asynchronous post back.

You need to view the trace message when an unhandled exception occurs during an asynchronous post back.

What should you do?

Set the Debug attribute of the @Page directive to True.

Set the ScriptMode property of the ScriptManager control to Debug.

Add the following code to the end of the Page_Error event handler:string script = string.Format("Sys.Debug.trace('{0}')", Trace.ToString());Page.ClientScript.RegisterStartupScript(this.ClientID, script);

Page 150: 70562 (1)

Use the trace viewer tool (Trace.axd) to view the message.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-036 Jump to Question ID

Question 60 Explanation:

You should use Trace.axd to view the message. When asynchronous post backs occur,

only regions of a page are updated. The entire page is not reloaded. This means that

the page output generated by the TraceContext class will not be updated during an

asynchronous post back. However, the trace messages still get written to Trace.axd.

You should not set the ScriptMode property of the ScriptManager control to Debug. This

property determines whether the ScriptManager control should render release or debug

versions of Asynchronous JavaScript and XML (AJAX) scripts.

You should not call the RegisterStartupScript method of the ClientScriptManager class.

After an asynchronous post back, the script would not be registered on the page

because the entire page would not be reloaded. Also, the Sys.Debug.trace AJAX

function does not implement ASP.NET tracing. It simply writes messages to a TextArea

element that has an ID of TraceConsole.

You should not set the Debug attribute of the @Page directive to True. This allows

ASP.NET to compile the page with debug symbols. It has no effect on ASP.NET trace

messages.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.3 Debug unhandled exceptions when using ASP.NET AJAX.

Page 151: 70562 (1)

References:

1. Debugging and Tracing AJAX Applications Overview

Click here for further information

MSDN, Microsoft

2. ASP.NET Tracing Overview

Click here for further information

MSDN, Microsoft

Question 61 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You enable view state on all pages in the application. You discover that some pages contain large amounts of data that travel between the Web server and the user's browser.

You need to modify the application to store view state in a database.

What should you do? (Each correct answer presents part of the solution. Choose two.)

Define a control adapter in a browser definition file of the App_Browsers folder.

Set the historySize attribute of the sessionPageState element to 0 in the Web.config file.

Set the enableViewState attribute of the pages element to false in the Web.config file.

Implement a class that derives from PageAdapter and override the GetStatePersister method.

Set the enableViewStateMac attribute of the pages element to true in the Web.config file.

Page 152: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-074 Jump to Question ID

Question 61 Explanation:

You should implement a class that derives from PageAdapter and override the

GetStatePersister method. This method returns an instance of the PageStatePersister

class, which is responsible for saving and retrieving view state and control state for a

page.

You should define a control adapter in a browser definition file of the App_Browsers

folder. This allows you to force all pages in the application to use the new page adapter

to store view state on the server. For example, your browser definition file might

contain the following content:

<browsers>

<browser refID="Default">

<controlAdapters>

<adapter

controlType="System.Web.UI.Page"

adapterType="BcdTrain.SqlServerPageStatePageAdapter" />

</controlAdapters>

</browser>

</browsers>

This definition specifies a custom page adapter named SqlServerPageStatePageAdapter

for all pages.

You should not set the enableViewStateMac attribute of the pages element to true in

the Web.config file. This attribute specifies whether view state should be verified after a

post back.

You should not set the historySize attribute of the sessionPageState element to 0 in the

Web.config file. This attribute specifies the maximum number of pages that can have

view state and control state stored in session state at a time. The sessionPageState

element is used by the SessionPageStatePersister class.

You should not set the enableViewState attribute of the pages element to false in the

Web.config file. This attribute specifies whether or not view state is enabled for the

application.

Page 153: 70562 (1)

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.5 Implement session state, view state, control state, cookies, cache, or application

state.

References:

1. SessionPageStatePersister Class

Click here for further information

MSDN, Microsoft

2. ASP.NET 2.0 Page State Persister

Click here for further information

MSDN, Microsoft

3. Browser Definition File Schema (browsers Element)

Click here for further information

MSDN, Microsoft

4. PageAdapter.GetStatePersister Method

Click here for further information

MSDN, Microsoft

5. PageStatePersister Class

Click here for further information

MSDN, Microsoft

Page 154: 70562 (1)

Question 62 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You host the Web application on a Web farm that consists of three Web servers.

You need to configure the Web application for session state to meet the following requirements:

* Session state data should not be lost if a server fails. * Session state must be maintained across browser requests by the same user.

You need to configure the Web.config file to meet these requirements. Your solution must not require you to write code.

Which configuration should you use?

<sessionState mode="SQLServer"/>

<sessionState mode="StateServer"/>

<sessionState mode="Custom"/>

<sessionState mode="InProc"/>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-055 Jump to Question ID

Question 62 Explanation:

You should set the mode attribute of the sessionState element to SQLServer. This

causes session state to be stored in a SQL Server database. This mechanism provides

failover support. You can configure a SQL Server cluster to access the session state

database. If one node in the cluster fails, another node can continue to serve requests.

This mechanism also provides support for a Web farm because session state is not

stored in memory on each Web server. On a Web farm, subsequent requests from the

Page 155: 70562 (1)

same user might not be directed to the same Web server.

You should not set the mode attribute of the sessionState element to Custom. This

requires you to implement a custom session state provider.

You should not set the mode attribute of the sessionState element to InProc. This uses

in-process session state, which stores session state in memory on each Web server.

This means that session state would not be maintained across browser requests if the

requests are redirected to different servers.

You should not set the mode attribute of the sessionState element to StateServer. This

requires you to use the ASP.NET state service to store session state. Although session

state would be available to all servers in the Web farm, the ASP.NET state service does

not provide failover support. If the server hosting the ASP.NET state service fails, then

session state data is lost.

Objective:

List all questions for this objective</P< td>

Configuring and Deploying Web

Applications

Sub-Objective:

1.4 Configure session state by using Microsoft SQL Server, State Server, or InProc.

References:

1. ASP.NET Session State Overview

Click here for further information

MSDN, Microsoft

Page 156: 70562 (1)

Question 63 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following code exists on a page (line numbers are included for reference only):

01 string connStr = WebConfigurationManager.ConnectionStrings[0].ConnectionString; 02 using (SqlConnection conn = new SqlConnection(connStr)) 03 { 04 SqlCommand cmd = new SqlCommand("GetMenuItems", conn); 05 cmd.CommandType = CommandType.StoredProcedure; 06 conn.Open(); 07 08 }

The GetMenuItems stored procedure returns XML in the following format:

<MenuItems> <MenuItem ID="Item1" Text="Item 1" Image="Item1.gif" NavigateUrl="Item1.aspx"/> <MenuItem ID="Item2" Text="Item 2" Image="Item2.gif" NavigateUrl="Item2.aspx"/> </MenuItems>

You need to programmatically insert the string Panel into the ID attribute of each MenuItem element.

Which code segment should you insert at line 07?

SqlDataAdapter adapter = new SqlDataAdapter(cmd, conn);DataSet ds = new DataSet();adapter.Fill(ds);ds.Tables[0].Select("//@ID").SetValue("Panel{0}", 0);

XmlDocument doc = new XmlDocument();using (XmlReader reader = cmd.ExecuteXmlReader()){doc.Load(reader);}foreach (XmlNode node in doc.SelectNodes("//@ID")){node.Value = node.Value.Insert(0, "Panel");}

SqlDataAdapter adapter = new SqlDataAdapter(cmd, conn);DataSet ds = new DataSet();

Page 157: 70562 (1)

adapter.Fill(ds);XmlDataDocument doc = new XmlDataDocument(ds);using (XmlReader reader = cmd.ExecuteXmlReader()){doc.Load(reader);}foreach (XmlNode node in doc.SelectNodes("//@ID")){node.Value = node.Value.Insert(0, "Panel");}

SqlDataAdapter adapter = new SqlDataAdapter(cmd, conn);DataSet ds = new DataSet();adapter.Fill(ds);ds.Tables[0].Select().SetValue("//@ID=Panel{0}", 0);

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-030 Jump to Question ID

Question 63 Explanation:

You should create an instance of XmlDocument, call the ExecuteXmlReader method of

the SqlCommand instance, and pass the returned XmlReader instance as a parameter

to the Load method of the XmlDocument instance. This creates an XmlDocument

instance that contains the XML returned from the stored procedure. The XmlDocument

class implements the XML Document Object Model (DOM), which provides an in-

memory representation of an XML document or data stream. The class implements the

IXPathNavigable interface, which allows you to execute XPath queries on the document.

The SelectNodes method of the XmlDocument class returns a collection of XmlNode

instances representing XML nodes that match the specified XPath expression. The

expression //@ID indicates to return all ID attribute nodes in the document. You should

modify the Value property of each returned XmlNode instance to set the new value of

the ID attribute.

You should not call the SetValue method of the returned DataRow array from a call to

the Select method of a DataTable instance. The SetValue method of an array allows you

to replace the value of an array element at the specified index. In this scenario, it

allows you to replace the entire DataRow instance at the specified index.

You should not call the Load method of an XmlDataDocument instance if the instance is

already synchronized with a DataSet instance that contains data. This would throw an

exception. You synchronize an XmlDataDocument instance with a DataSet instance by

passing the DataSet instance to the XmlDataDocument constructor.

Page 158: 70562 (1)

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.1 Read and write XML data.

References:

1. Select Nodes Using XPath Navigation

Click here for further information

MSDN, Microsoft

2. Reading an XML Document into the DOM

Click here for further information

MSDN, Microsoft

Question 64 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You need to add a Button control to a page. When it is clicked, the Button control must display a confirmation message box to the user. The Button control should post back to the server only if the user clicks OK in the confirmation message box.

You need to declare the Button control.

Which declaration should you use?

Page 159: 70562 (1)

<asp:Button runat="server" Text="Submit"OnClientClick="confirm('Are you sure?'); return true;"/>

<asp:Button runat="server" Text="Submit"OnClientClick="confirm('Are you sure?')"/>

<asp:Button runat="server" Text="Submit"OnClientClick="return confirm('Are you sure?')"/>

<asp:Button runat="server" Text="Submit"OnClientClick="confirm('Are you sure?'); return false;"/>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-060 Jump to Question ID

Question 64 Explanation:

You should set the OnClientClick property of the Button control to the following

JavaScript statement:

return confirm('Are you sure?')

The OnClientClick property specifies a JavaScript statement or function that must run

before the Button control posts back to the server. If the statement or function returns

true, the control posts back to the server. If not, the control does not post back to the

server. The built-in confirm function displays a confirmation message box to the user. It

returns true if a user clicks the OK button in the confirmation message dialog box, and

it returns false if the user clicks the Cancel button.

You should not set the OnClientClick property to the following statement:

confirm('Are you sure?')

This statement does not return the value from the confirm function.

You should not set the OnClientClick property to the following statement:

confirm('Are you sure?'); return false;

Page 160: 70562 (1)

This statement returns false after displaying the confirmation dialog box. This would

prevent the Button control from ever posting back to the server.

You should not set the OnClientClick property to the following statement:

confirm('Are you sure?'); return true;

This statement returns true after displaying the confirmation dialog box. This would

cause the Button control to always post back to the server.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.5 Consume standard controls.

References:

1. Button.OnClientClick Property

Click here for further information

MSDN, Microsoft

Question 65 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. A Hypertext Transfer Protocol (HTTP) handler is implemented to generate Human Interactive Proof (HIP) images.

Page 161: 70562 (1)

You need to have the current page invoke the handler and automatically continue executing after the handler completes execution.

What should you do?

Set the RedirectLocation property of the HttpResponse class.

Call the Redirect method of the HttpResponse class.

Call the Execute method of the HttpServerUtility class.

Call the Transfer method of the HttpServerUtility class.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-071 Jump to Question ID

Question 65 Explanation:

You should call the Execute method of the HttpServerUtility class. This method allows

ASP.NET to execute an HTTP handler from a page without transferring or redirecting the

request from the page. When the handler completes execution, the original page will

resume execution.

You should not call the Redirect method of the HttpResponse class. This method would

instruct the browser to request the handler, which would transfer the request from the

current page.

You should not call the Transfer method of the HttpServerUtility class. This method

would unconditionally transfer the current request to the handler. The original page

would not automatically resume execution after the handler completes execution.

You should not set the RedirectLocation property of the HttpResponse class. This

method would instruct the browser to request the handler, which would transfer the

request from the current page.

Page 162: 70562 (1)

Objective:

List all questions for this objective</P< td>

Programming Web Applications

Sub-Objective:

7.6 Handle events and control page flow.

References:

1. HttpServerUtility.Execute Method

Click here for further information

MSDN, Microsoft

2. How to: Redirect Users to Another Page

Click here for further information

MSDN, Microsoft

Question 66 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. The following markup exists on a page:

<asp:Wizard ID="_wizard" runat="server" ActiveStepIndex="0" OnNextButtonClick="OnNext"> <WizardSteps> <asp:WizardStep ID="_welcomeStep" runat="server" Title="Welcome"> This wizard helps you create a survey. </asp:WizardStep> <asp:WizardStep ID="_chooseQuestionsStep" runat="server" Title="Choose Your Questions"> <asp:GridView ID="_questionsGridView" runat="server"/> <asp:CheckBox ID="_checkBox" Checked="true" runat=server Text="Create

Page 163: 70562 (1)

Questions"/> </asp:WizardStep> <asp:WizardStep ID="_createQuestionsStep" runat="server" Title="Create Your Questions"> <cc:QuestionEditor ID="_question" runat="server"/><br> <asp:Button ID="_addQuestion" runat="server"/> </asp:WizardStep> <asp:WizardStep ID="_finishStep" runat="server" Title="Done"> </asp:WizardStep> </WizardSteps> </asp:Wizard>

You need to implement the OnNext event handler so that the third step (Create Your Questions) is skipped if the user clears the Create Questions check box option.

Which code segment should you use?

protected void OnNext(object sender, WizardNavigationEventArgs e){if (e.CurrentStepIndex == _wizard.WizardSteps.IndexOf(_chooseQuestionsStep)&& !_checkBox.Checked){_wizard.MoveTo(_finishStep);}}

protected void OnNext(object sender, WizardNavigationEventArgs e){if (e.CurrentStepIndex == _wizard.WizardSteps.IndexOf(_chooseQuestionsStep)&& !_checkBox.Checked){_wizard.MoveTo(_finishStep);e.Cancel = true;}}

protected void OnNext(object sender, WizardNavigationEventArgs e){if (e.CurrentStepIndex == _wizard.WizardSteps.IndexOf(_chooseQuestionsStep)&& _checkBox.Checked){e.Cancel = false;}}

protected void OnNext(object sender, WizardNavigationEventArgs e){if (e.CurrentStepIndex == _wizard.WizardSteps.IndexOf(_chooseQuestionsStep)&& !_checkBox.Checked){_wizard.MoveTo(_finishStep);}else{e.Cancel = true;

Page 164: 70562 (1)

}}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-029 Jump to Question ID

Question 66 Explanation:

You should implement the event handler to call the MoveTo method of the Wizard class

if the current step is the Choose Your Questions step and the Checked property of the

_checkBox control is false. The NextButtonClick event is raised whenever a user clicks

the Next button of the Wizard control. This event defines a WizardNavigationEventArgs

parameter that specifies the current step and the next defined step, as indicated by the

CurrentStepIndex and NextStepIndex properties of the WizardNavigationEventArgs

class. This class also defines a Cancel property that allows you to cancel automatic or

manual navigation. You can perform manual navigation by calling the MoveTo method of

the Wizard class. The MoveTo method changes the ActiveStepIndex property of the

Wizard control. If the ActiveStepIndex property is not changed, the Wizard

automatically navigates to the next defined step unless

WizardNavigationEventArgs.Cancel is set to true.

You should not set the Cancel property of the WizardNavigationEventArgs class to true

after calling the MoveTo method of the Wizard class. This would cancel manual

navigation.

You must call the MoveTo method if the Checked property of the _checkBox control is

false. Otherwise, the Wizard control will automatically navigate to the next defined step.

You should not set the Cancel property of the WizardNavigationEventArgs class to true if

the current step is not the Choose Your Questions step. Because the event handler

handles the NextButtonClick event for all steps, this would prevent navigation from all

other steps.

Page 166: 70562 (1)

You create a Web application by using Microsoft ASP.NET 3.5. A Windows Communication Foundation (WCF) service named TimeService contains a method named GetTime that takes no parameters and returns the current time from a government time server. You register the proxy to the service on a page. The proxy is defined in the BcdTrain.Services namespace.

You need to call the GetTime method and display it in an alert window.

Which code segment should you use?

function CallService(){var result = null;BcdTrain.Services.TimeService.GetTime(result);window.alert(result);}

function CallService(){var result = BcdTrain.Services.TimeService.GetTime();window.alert(result);}

function CallService(){BcdTrain.Services.TimeService.GetTime(OnSuccess);}function OnSuccess(result){window.alert(result);}

function CallService(){BcdTrain.Services.TimeService.GetTime(OnSuccess);}function OnSuccess(){window.alert(BcdTrain.Services.TimeService.result);}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-063 Jump to Question ID

Question 67 Explanation:

You should use the following code segment:

Page 167: 70562 (1)

function CallService()

{

BcdTrain.Services.TimeService.GetTime(OnSuccess);

}

function OnSuccess(result)

{

window.alert(result);

}

This code calls the GetTime function of the TimeService proxy object, passing to it a

callback function that retrieves the result. WCF service proxies execute remote method

calls asynchronously. Therefore, you must use a callback function to access the result.

The callback function must accept a single parameter that specifies the return value of

the method call.

You should not use the following code segment:

function CallService()

{

var result = BcdTrain.Services.TimeService.GetTime();

window.alert(result);

}

This code calls the GetTime function without passing in a callback function. This

function will return immediately, preventing you from accessing the return value of the

method call.

You should not use the following code segment:

function CallService()

{

BcdTrain.Services.TimeService.GetTime(OnSuccess);

}

function OnSuccess()

{

window.alert(BcdTrain.Services.TimeService.result);

}

This code does not define the callback function correctly. The callback function must

contain a parameter that specifies the return value from the method call.

You should not use the following code segment:

Page 168: 70562 (1)

function CallService()

{

var result = null;

BcdTrain.Services.TimeService.GetTime(result);

window.alert(result);

}

This code calls the GetTime function, passing to it a null parameter. If you pass a

parameter to this function, you must pass a callback function to the parameter so that

you can retrieve the return value of the method call.

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.3 Consume services from client scripts.

References:

1. Exposing WCF Services to Client Script

Click here for further information

MSDN, Microsoft

2. Calling Web Services from Client Script

Click here for further information

MSDN, Microsoft

Page 169: 70562 (1)

Question 68 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You add the following markup to implement partial rendering on a page:

<asp:ScriptManager ID="_scriptManager" runat="server"/> <asp:UpdatePanel ID="updatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="label1" runat="server"/> <asp:Button ID="updateButton" runat="server" Text="Update"/> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="updatePanel2" runat="server"> <ContentTemplate> <asp:Label ID="label2" runat="server"/> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="updateButton"/> </Triggers> </asp:UpdatePanel>

When you click the Button control named updateButton, you want only the content in the updatePanel2 control to be updated. The updatePanel2 control should be updated only when the Button control named updateButton is clicked.

You need to configure the page accordingly.

What should you do? (Each correct answer presents part of the solution. Choose three.)

Replace AsyncPostBackTrigger with PostBackTrigger.

Set the UpdateMode property of updatePanel2 to Conditional.

Set the ChildrenAsTriggers property of updatePanel1 to false.

Set the ChildrenAsTriggers property of updatePanel2 to false.

Set the UpdateMode property of updatePanel1 to Conditional.

Set the UpdateMode property of updatePanel2 to Always.

Page 170: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-066 Jump to Question ID

Question 68 Explanation:

You should set the UpdateMode property to Conditional on both UpdatePanel controls.

By default, this property is set to Always. This means that an UpdatePanel control is

always updated whenever an asynchronous post back originates from anywhere on the

page.

You should set the ChildrenAsTriggers property of updatePanel1 to false. This property

determines whether child controls cause the parent UpdatePanel control to update

during an asynchronous post back. By default, this property is set to true. To prevent

the updateButton control from updating the updatePanel1 control, you should set this

property to false.

You should not replace AsyncPostBackTrigger with PostBackTrigger. PostBackTrigger

specifies a child control of the UpdatePanel control that must cause a post back instead

of an asynchronous post back.

You should not set the UpdateMode property of updatePanel2 to Always. This would

cause the control to be updated whenever an asynchronous post back originates from

anywhere on the page.

You should not set the ChildrenAsTriggers property of updatePanel2 to false. There are

no child controls of updatePanel2 that can cause post backs.

Objective:

List all questions for this objective</P< td>

Working with ASP.NET AJAX and

Client-Side Scripting

Sub-Objective:

5.1 Implement Web Forms by using ASP.NET AJAX.

References:

Page 171: 70562 (1)

1. UpdatePanel Control Overview

Click here for further information

MSDN, Microsoft

2. UpdatePanel.UpdateMode Property

Click here for further information

MSDN, Microsoft

3. UpdatePanel.ChildrenAsTriggers Property

Click here for further information

MSDN, Microsoft

4. PostBackTrigger Class

Click here for further information

MSDN, Microsoft

Question 69 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You use the ListView control to display product images on a page. You must render each image as a column in a table.

Which declaration should you use?

<asp:ListView runat="server" ItemPlaceholderID="listItem"><LayoutTemplate><table><tr id="listItem"/><td><asp:Image ImageUrl='<%# Eval("Image") %>' /></td></tr></table></LayoutTemplate></asp:ListView>

Page 172: 70562 (1)

<asp:ListView runat="server" ItemPlaceholderID="listItem"><LayoutTemplate><table><tr id="listItem"/><td><asp:Image ImageUrl='<%# Eval("Image") %>' /></td></tr></table></LayoutTemplate></asp:ListView>

<asp:ListView runat="server"><LayoutTemplate><table runat="server"><tr id="listItem" runat="server"/></table></LayoutTemplate><ItemTemplate><td runat="server"><asp:Image ImageUrl='<%# Eval("Image") %>' /></td></ItemTemplate></asp:ListView>

<asp:ListView runat="server" ItemPlaceholderID="listItem"><LayoutTemplate><table runat="server"><tr id="listItem" runat="server"/></table></LayoutTemplate><ItemTemplate><td runat="server"><asp:Image ImageUrl='<%# Eval("Image") %>' /></td></ItemTemplate></asp:ListView>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-058 Jump to Question ID

Question 69 Explanation:

You should use the following declaration:

<asp:ListView runat="server" ItemPlaceholderID="listItem">

<LayoutTemplate>

<table runat="server">

<tr id="listItem" runat="server"/>

</table>

Page 173: 70562 (1)

</LayoutTemplate>

<ItemTemplate>

<td runat="server">

<asp:Image ImageUrl='<%# Eval("Image") %>' />

</td>

</ItemTemplate>

</asp:ListView>

This markup sets the ItemPlaceholderID property to listItem. When the ListView control

renders items, it searches for a server control inside the LayoutTemplate element that

that has an ID equal to listItem. For each data bound item, the ListView control adds

the content inside the ItemTemplate element as a child of the found server control. The

LayoutTemplate property defines the complete layout of the control. The ItemTemplate

property defines the template for a single item.

You should not use the following declaration:

<asp:ListView runat="server" ItemPlaceholderID="listItem">

<LayoutTemplate>

<table>

<tr id="listItem"/>

<td>

<asp:Image ImageUrl='<%# Eval("Image") %>' />

</td>

</tr>

</table>

</LayoutTemplate>

</asp:ListView>

This markup does not define the ItemTemplate property. You must define this property

when using the ListView control.

You should not use the following declaration:

<asp:ListView runat="server">

<LayoutTemplate>

<table runat="server">

<tr id="listItem" runat="server"/>

</table>

</LayoutTemplate>

<ItemTemplate>

<td runat="server">

<asp:Image ImageUrl='<%# Eval("Image") %>' />

Page 174: 70562 (1)

</td>

</ItemTemplate>

</asp:ListView>

This markup does not explicitly set the ItemPlaceholderID property. The default value of

this property is itemPlaceholder. The LayoutTemplate element must contain a server

control that has an ID equal to the value of the ItemPlaceholderID property. This

markup does not contain a server control in the LayoutTemplate element with this ID.

You should not use the following declaration:

<asp:ListView runat="server" ItemPlaceholderID="listItem">

<LayoutTemplate>

<table>

<tr id="listItem"/>

<td>

<asp:Image ImageUrl='<%# Eval("Image") %>' />

</td>

</tr>

</table>

</LayoutTemplate>

</asp:ListView>

This markup does not define the ItemTemplate property. You must define this property

when using the ListView control.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.1 Implement data-bound controls.

References:

1. ListView Web Server Control Overview

Page 175: 70562 (1)

Click here for further information

MSDN, Microsoft

Question 70 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. A page named Books.aspx calls the following SQL query to display titles of books in a GridView control:

SELECT BookID, Title FROM Book

Another page named BookInfo.aspx uses the ID query string parameter to display a specific book. The book is identified by the BookID field returned from the SQL query. The title of the book is represented by the Title field returned from the query. You add a HyperLink control to a template field of the GridView control.

You need to declare the HyperLink control so that it displays book titles and links the user to BookInfo.aspx to view the selected book.

Which declaration should you use?

<asp:HyperLink Text='<%= Eval("Title") %>' NavigateUrl='<%= Eval("BookID", "BookInfo.aspx?ID=BookID")%>'/>

<asp:HyperLink Text='<%# Eval("Title") %>' NavigateUrl='<%# Eval("BookID", "BookInfo.aspx?ID={0}")%>'/>

<asp:HyperLink Text='<%= Eval("Title") %>' NavigateUrl='<%= Eval("BookInfo.aspx?ID=BookID")%>'/>

<asp:HyperLink Text='<%# Eval("Title") %>' NavigateUrl='<%# Eval("BookInfo.aspx?ID=BookID")%>'/>

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application

Page 176: 70562 (1)

Development (C#) (Preview) Question ID: jehMS_70-562CS-065 Jump to Question ID

Question 70 Explanation:

You should use the following declaration:

<asp:HyperLink

Text='<%# Eval("Title") %>'

NavigateUrl='<%# Eval("BookID", "BookInfo.aspx?ID={0}")%>'/>

This markup uses data binding syntax to set the Text and NavigateUrl properties. The

Eval method takes a parameter that specifies a field or property of the data item

currently being bound. It optionally accepts a second parameter that defines a format

string, which allows you to replace a format placeholder in the string with the value of

the specified field or property. The syntax Eval("BookID", "BookInfo.aspx?ID={0}")

indicates to evaluate the value of the BookID field. However, the value of the field

should replace the {0} placeholder defined in the second parameter. For example, if the

value of the BookID field is 1, then the NavigateUrl property evaluates to the following

value after the data is bound: BookInfo.aspx?ID=1.

You should not use the following declaration:

<asp:HyperLink

Text='<%= Eval("Title") %>'

NavigateUrl='<%= Eval("BookInfo.aspx?ID=BookID")%>'/>

This markup uses <%= %>, which is not the correct data binding syntax. It represents

a code render block.

You should not use the following declaration:

<asp:HyperLink

Text='<%# Eval("Title") %>'

NavigateUrl='<%# Eval("BookInfo.aspx?ID=BookID")%>'/>

The NavigateUrl property does not specify the correct data binding syntax. The first

parameter to the Eval method should specify the field to be bound.

You should not use the following declaration:

<asp:HyperLink

Text='<%= Eval("Title") %>'

Page 177: 70562 (1)

NavigateUrl='<%= Eval("BookID", "BookInfo.aspx?ID=BookID")%>'/>

This markup uses <%= %>, which is not the correct data binding syntax. Also, the

second parameter to this method does not include a format placeholder that the BookID

field value should replace.

Objective:

List all questions for this objective</P< td>

Working with Data and Services

Sub-Objective:

3.5 Bind controls to data by using data binding syntax.

References:

1. Data Binding Expression Syntax

Click here for further information

MSDN, Microsoft

2. Data-Binding Expression Syntax

Click here for further information

MSDN, Microsoft

Question 71 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You host the application in Microsoft Internet Information Services (IIS) 6.0. When you browse to the application, your browser displays the following error message:

Server Application Unavailable

Page 178: 70562 (1)

The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.

You then view the Application event log and discover the following message:

It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process.

You need to solve this problem.

What should you do? (Each correct answer presents a complete solution. Choose two.)

Change the IIS isolation mode.

Assign your application to another application pool.

Configure all applications that are part of your application's application pool to use the same version of ASP.NET.

Run the ASP.NET Registration Tool (Aspnet_regiis.exe).

Restart the application pool that hosts the application.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-050 Jump to Question ID

Question 71 Explanation:

You should configure all applications that are part of your application's pool to use the

same version of ASP.NET. To do this, change the ASP.NET version selection on the

ASP.NET tab in the Properties dialog box of the IIS application. Web applications run

within a worker process that is assigned to an application pool. The worker process can

only support one version of ASP.NET.

Another solution is to assign your application to another application pool. This is

necessary if other applications in the same pool must use a different version of

ASP.NET.

You should not restart the application pool that hosts the application. The problem is

that multiple applications that use different ASP.NET versions are assigned to the same

application pool.

Page 179: 70562 (1)

You should not run Aspnet_regiis.exe. This tool allows you to install ASP.NET and update

script maps for applications. Script maps associate applications with specific ASP.NET

versions. In this scenario, the problem is that multiple applications that use different

ASP.NET versions are assigned to the same application pool.

You should not change the IIS isolation mode. The IIS isolation mode determines how

Web applications run. In the default mode, a worker process runs with the Network

Service identity. Web applications run within the worker process, and one worker

process is assigned to each application pool. In the IIS 5.0 mode, all Web applications

run within the IIS process.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.5 Debug deployment issues.

References:

1. Configuring an ASP.NET Application for an ASP.NET Version

Click here for further information

MSDN, Microsoft

2. Configuring Isolation Modes (IIS 6.0)

Click here for further information

Microsoft TechNet, Microsoft

3. Working with Application Pools and Web Applications

Click here for further information

MSDN, Microsoft

Page 180: 70562 (1)

Question 72 / 75 Mark for Review

You create a custom control for a Microsoft ASP.NET 3.5 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 need to extend this control so that its Radius property can be set from JavaScript.

What should you do?

Add a method named GetRadius that returns the Radius property, and apply the ScriptMethod attribute to the method.

Implement the IScriptControl interface.

Derive the class from ScriptControlDescriptor instead of Control.

Apply the ScriptService attribute to the class.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-027 Jump to Question ID

Question 72 Explanation:

Page 181: 70562 (1)

You should implement the IScriptControl interface. This interface defines two methods

named GetScriptDescriptors and GetScriptReferences. The GetScriptDescriptors method

returns a collection of ScriptDescriptor instances that represent client components. The

GetScriptReferences method returns a collection of ScriptReference instances that

represent embedded script resources required by the control.

You should not apply the ScriptService attribute to the class. This attribute marks a Web

service as one that is accessible from ASP.NET Asynchronous JavaScript and XML

(AJAX). This attribute allows the Web service to generate a JavaScript Object Notation

(JSON) script that a JavaScript client application can use to call the Web service.

You should not apply the ScriptMethod attribute to a method named GetRadius. This

attribute allows you to control the response format of a Web method that is accessible

from ASP.NET AJAX.

You should not derive the class from ScriptControlDescriptor instead of Control. You

should return instances of ScriptControlDescriptor from the GetScriptDescriptors

method. ScriptControlDescriptor derives from ScriptDescriptor. ScriptControlDescriptor

maps properties of a control to client-side properties.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Controls

Sub-Objective:

2.3 Create and consume custom controls.

References:

1. ScriptManager Enables AJAX In Your Web Apps

Click here for further information

MSDN, Microsoft

2. Adding ASP.NET AJAX Client Capabilities to a Web Server Control

Click here for further information

MSDN, Microsoft

Page 182: 70562 (1)

3. An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET

Click here for further information

MSDN, Microsoft

Question 73 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You deploy the application to a test server and enable debugging. The application is hosted in Microsoft Internet Information Services (IIS) 6.0 and uses the default identity. Integrated Windows authentication is enabled and anonymous access is disabled. You do not have administrative rights on the test server. The following configuration exists in the Web.config file:

<authentication mode="Windows"/> <identity impersonate="false"/> <customErrors mode="On" defaultRedirect="GenericError.aspx"/> <authorization> <deny users="?"/> </authorization>

You need to configure the Web.config file to allow you to debug the application from your development computer.

What configuration should you add to the Web.config file?

<authentication mode="Forms"/>

<identity impersonate="true"/>

<authorization><allow users="?"/></authorization>

<authorization><allow users="*"/></authorization>

Page 183: 70562 (1)

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-046 Jump to Question ID

Question 73 Explanation:

You should enable impersonation by setting the impersonate attribute of the identity

element to true. Users who are not administrators cannot debug processes that run

under different accounts. Impersonation allows the Web application to run as the

authenticated user.

You should not enable Forms authentication by setting the mode attribute of the

authentication element to Forms. The authentication mode does not determine the

identity under which the application runs. It determines how the user is authenticated.

You should not reconfigure the authorization element. This element grants or denies

access to users. An allow element grants access, and a deny element denies access.

The users attribute specifies the users that should be granted or denied access. The (*)

symbol specifies all users, and the (?) symbol specifies anonymous users.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Sub-Objective:

4.2 Set up an environment to perform remote debugging.

References:

1. How to: Set Up Remote Debugging

Click here for further information

MSDN, Microsoft

2. Debugging Web Pages Overview

Click here for further information

MSDN, Microsoft

Page 184: 70562 (1)

3. How to: Debug Web Applications on a Remote Server

Click here for further information

MSDN, Microsoft

4. Remote Debugging Components

Click here for further information

MSDN, Microsoft

Question 74 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You add a FileUpload control named fileUpload to a page. The directory structure of the Web application is as follows:

* Web Application Root (C:\WebApps\Crm) **** UploadedFiles (D:\UploadedFiles)

UploadedFiles is a virtual directory of the root directory. The physical directory associated with the UploadedFiles virtual directory might change in the future.

You need to write code to upload the selected file to the UploadedFiles virtual directory of the Web application.

Which code segment should you use?

if (fileUpload.HasFile){string path = "/UploadedFiles/";fileUpload.PostedFile.SaveAs(path + fileUpload.FileName);}

if (fileUpload.HasFile){string path = "~/UploadedFiles/";fileUpload.PostedFile.SaveAs(path + fileUpload.FileName);}

if (fileUpload.HasFile){string path = Server.MapPath("~/UploadedFiles/");

Page 185: 70562 (1)

fileUpload.PostedFile.SaveAs(path + fileUpload.FileName);}

if (fileUpload.HasFile){string path = "UploadedFiles/";fileUpload.PostedFile.SaveAs(path + fileUpload.FileName);}

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-012 Jump to Question ID

Question 74 Explanation:

You should convert the virtual path to the saved file into a physical path. The FileUpload

control exposes a PostedFile property, which is an instance of the HttpPostedFile class.

This class contains a SaveAs method that allows you to save an uploaded file to a

physical location accessible by the Web server. However, the value passed as a

parameter to this method must represent a physical path or file share, not a virtual

path. To convert the virtual path to a physical path, you should call the MapPath method

of the current HttpServerUtility instance. Because you must save the file to the

UploadedFiles virtual directory of the Web application, you must specify

~/UploadedFiles as the virtual directory.

You should not specify ~/UploadedFiles as the directory to the SaveAs method. You

must specify a physical path to this method, not a virtual path.

You should not specify UploadedFiles as the directory to the SaveAs method. This would

attempt to save the file in a subdirectory named UpoadedFiles of the current working

directory of the application.

You should not specify /UploadedFiles as the directory to the SaveAs method. You must

specify a physical path to this method, not a virtual path.

Objective:

List all questions for this objective</P< td>

Consuming and Creating Server

Page 186: 70562 (1)

Controls

Sub-Objective:

2.5 Consume standard controls.

References:

1. FileUpload Web Server Control Overview

Click here for further information

MSDN, Microsoft

2. How to: Upload Files with the FileUpload Web Server Control

Click here for further information

MSDN, Microsoft

Question 75 / 75 Mark for Review

You create a Web application by using Microsoft ASP.NET 3.5. You host the application in Microsoft Internet Information Services 7.0. When you browse to the application, your browser displays the following error message:

Service Unavailable

HTTP Error 503. The service is unavailable.

You can successfully browse to other applications that are part of the same IIS Web site. All hosted applications use ASP.NET 3.5. No previous version of ASP.NET is installed.

You need to solve this problem.

What should you do?

Run the ServiceModel Metadata Utility tool (Svcutil.exe).

Page 187: 70562 (1)

Change the pipeline mode associated with the application pool that hosts the application.

Run the ASP.NET Registration Tool (Aspnet_regiis.exe).

Ensure that the application pool that hosts the application is started.

Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application Development (C#) (Preview) Question ID: jehMS_70-562CS-049 Jump to Question ID

Question 75 Explanation:

You should ensure that the application pool that hosts the application is started. Web

applications run within a worker process that is assigned to an application pool. If the

application pool is not started, the worker process does not run for that application

pool.

You should not run Aspnet_regiis.exe. This tool allows you to install ASP.NET and update

script maps for applications. Script maps associate applications with specific ASP.NET

versions. In this scenario, no previous versions of ASP.NET are installed. Therefore,

script maps do not need to be updated.

You should not change the pipeline mode associated with the application pool that hosts

the application. IIS 7.0 supports two pipeline modes: integrated and classic. The

integrated pipeline mode allows you to specify Web server settings in the

system.webServer section of an application's Web.config file. The classic mode

maintains backward compatibility with IIS 6.0.

You should not run Svcutil.exe. This tool allows you to generate code from service

metadata documents, such as Web Services Description Language (WSDL) documents.

Objective:

List all questions for this objective</P< td>

Troubleshooting and Debugging

Web Applications

Page 188: 70562 (1)

Sub-Objective:

4.5 Debug deployment issues.

References:

1. Moving an ASP.NET Application from IIS 6.0 to IIS 7.0

Click here for further information

MSDN, Microsoft

2. Working with Application Pools and Web Applications

Click here for further information

MSDN, Microsoft

3. Troubleshooting Internet Information Services

Click here for further information

MSDN, Microsoft

4. How to: Verify or Correct the IIS Configuration for an Application Pool

Click here for further information

MSDN, Microsoft

5. The HTTP status codes in IIS 7.0

Click here for further information

Microsoft Help and Support, Microsoft