[Free] Get all latest Microsoft 70-515 Actual Tests 31-40

Ensurepass

QUESTION 31

You are implementing a Web page that allows users to upload files to a Web server. The page includes a form that has a Submit button. You need to reject files larger than 1 MB. What should you do?

 

A.

Add an HTML input type= file control. Add an onSubmit handler to the form to check the file size and cancel the form submission if the file size is too large.

B.

Add an HTML input type= file control. Add an onChange handler to the input control to check the file size and cancel the upload if the file size is too large.

C.

Add an ASP.NET FileUpload control and configure it to run on the server. Add a server- side OnClick handler to the form’s Submit button to save the file only if the file size is allowed.

D.

Add an ASP.NET FileUpload control and configure it to run on the server. Add a server- side OnDataBinding handler that saves the file only if the file size is allowed.

 

Correct Answer: C

 

 

QUESTION 32

You are developing an ASP.NET Web page.

 

You add the following markup to the page.

 

<asp:FileUpload id=”FileUpload1″ runat=”server” />

 

<asp:Button id=”btnUpload” Text=”Upload selected file”

 

OnClick=”btnUpload_Click” runat=”server” />

 

<asp:Label id=”lblFeedback” runat=”server” />

 

You add the following code segment to the code-behind. (Line numbers are included for reference only.)

 

01 Protected Sub btnUpload_Click(ByVal sender As Object,

 

02 ByVal e As EventArgs) Handles btnUpload.Click

 

03 If () Then

 

04 Dim saveName As String =

 

05 Path.Combine(“c:uploadedfiles”,

 

06 FileUpload1.FileName)

 

07

 

08 lblFeedback.Text = “File successfully uploaded.”

 

09 Else

 

10 lblFeedback.Text = “File upload failed.”

 

11 End If

 

12

 

13 End Sub

 

You need to save the uploaded file and display a message to the user that indicates that the upload either succeeded or failed.

 

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

 

A.

Replace line 03 with the following code segment.

If (FileUpload1.HasFile) Then

B.

Replace line 03 with the following code segment.

If (FileUpload1.FileContent.Length > 0) Then

C.

Insert the following code segment at line 07.

FileUpload1.SaveAs(saveName)

D.

Insert the following code segment at line 07.

FileUpload1.FileContent.CopyTo(

New FileStream(saveName, FileMode.Open))

 

Correct Answer: AC

Explanation:

CHAPTER 4 Using Server Controls

Lesson 2: Exploring Specialized Server Controls

The FileUpload Control (page 202-204)

 

 

QUESTION 33

You create a Web page named TestPage.aspx and a user control named TestUserControl. ascx. TestPage.aspx uses TestUserControl.ascx as shown in the following line of code.

 

<uc:TestUserControl ID=”testControl” runat=”server”/>

 

On TestUserControl.ascx, you need to add a read-only member named CityName to return the value “New York”. You also must add code to TestPage.aspx to read this value.

 

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

 

A.

Add the following line of code to the TestUserControl.ascx.vb code-behind file.

Public ReadOnly Property CityName As String

Get

Return “New York”

End Get

End Property

B.

Add the following line of code to the TestUserControl.ascx.vb code-behind file.

Protected ReadOnly CityName As String = “New York”

C.

Add the following code segment to the TestPage.aspx.vb code-behind file.

Protected Sub Page_Load(ByVal sender As Object,

ByVal e As System.EventArgs) Handles Me.Load

Dim s As String = testControl.CityName

End Sub

D.

Add the following code segment to the TestPage.aspx.vb code-behind file.

Protected Sub Page_Load(ByVal sender As Object,

ByVal e As System.EventArgs) Handles Me.Load

Dim s As String = testControl.Attributes(“CityName”)

End Sub

 

Correct Answer: AC

Explanation:

CHAPTER 7 Creating Custom Web Controls

Lesson 1: Creating User Controls

Defining Properties in User Controls (page 337-339)

 

 

QUESTION 34

You are developing an ASP.NET MVC 2 application. A view contains a form that allows users to submit their first name. You need to display the value that is submitted, and you must ensure that your code avoids cross-site scripting. Which code segment should you use?

 

A.

<%: Model.FirstName%>

B.

<%= Model.FirstName %>

C.

<% Response.Write(Model.FirstName)%>

D.

<% Response.Write(HttpUtility.HtmlDecode( Model.FirstName))%>

 

Correct Answer: A

Explanation:

CHAPTER 14 Creating Websites with ASP.NET MVC 2

Lesson 2: Creating Models, Views, and Controllers Creating Views – Creating Strongly Typed Views (page 859)

 

 

QUESTION 35

You are implementing an ASP.NET AJAX page.

 

You add two UpdatePanel controls named pnlA and pnlB. pnlA contains an UpdatePanel control named pnlAInner in its content template.

 

You have the following requirements.

 

Update panels pnlA and pnlB must refresh their content only when controls that they contain cause a postback.

 

Update panel pnlAInner must refresh its content when controls in either pnlA or pnlB or pnlAInner cause a postback.

 

You need to configure the panels to meet the requirements.

 

What should you do?

 

A.

Set the UpdateMode of pnlA and pnlB to Conditional.

Set the UpdateMode of pnlAInner to Always.

B.

Set the UpdateMode of pnlA and pnlB to Conditional.

Set the UpdateMode of pnlAInner to Conditional, and add AsyncPostBackTrigger elements to its Triggers element for every control in pnlA.

C.

Set the UpdateMode of pnlA and pnlB to Always.

Set the UpdateMode of pnlAInner to Conditional.

D.

Set the UpdateMode of pnlA and pnlB to Always.

Set the UpdateMode of pnlAInner to Always, and add AsyncPostBackTrigger elements to its Triggers element for every control in pnlB.

 

Correct Answer: A

 

 

QUESTION 36

A Web service returns a list of system users in the following format.

 

<?xml version=”1.0″ ?>

 

<users>

 

<user id=”first”>

 

<name>Name of first user</name>

 

<email>first@contoso.com</email>

 

</user>

 

<user id=”second”>

 

<name>Name of second user</name>

 

<email>second@contoso.com</email>

 

</user>

 

</users>

 

You need to populate a drop-down menu with the IDs and names of the users from the Web service, in the order provided by the service.

 

Which code segment should you use?

 

A.

$.ajax({

type: “GET”,

url: serviceURL,

success: function(xml) {

$.each($(xml), function(i, item) {

$(“<option>”).attr(“value”, id)

.text(tx).appendTo(“#dropdown”);

});

}

});

B.

$.ajax({

type: “GET”,

url: serviceURL,

success: function(xml) {

$(xml).find(“user”).each(function() {

var id = $(this).id;

var tx = $(this).name.text;

$(“<option>”).attr(“value”, id)

.text(tx).appendTo(“#dropdown”);

});

}

});

C.

$.ajax({

type: “GET”,

url: serviceURL,

success: function(xml) {

$(xml).find(“user”).each(function() {

var id = $(this).attr(“id”);

var tx = $(this).find(“name”).text();

$(“<option>”).attr(“value”, id)

.text(tx).appendTo(“#dropdown”);

});

}

});

D.

$.ajax({

type: “GET”,

url: serviceURL,

success: function(xml) {

xml.find(“user”).each(function(node) {

var id = $(node).attr(“id”);

var tx = $(node).find(“name”).text();

$(“<option>”).attr(“value”, id)

.text(tx).appendTo(“#dropdown”);

});

}

});

 

Correct Answer: C

Explanation:

each() function

(http://api.jquery.com/each/)

CHAPTER 9 Working with Client-Side Scripting, AJAX, and jQuery Lesson 3: Implementing jQuery

Implementing AJAX with jQuery

 

 

QUESTION 37

You create a Web page that contains the following div.

 

<div id=”target”>

 

</div>

 

You have a JavaScript array named imageurls that contains a list of image URLs.

 

You need to write a JavaScript function that will insert images from the URLs into target.

 

Which code segment should you use?

 

A.

$(imageurls).each(function(i,url){

$(“<img/>”, url).append(“#target”);

});

B.

$(imageurls).each(function(i,url){

$(“#target”) += $(“<img/>”).attr(“src”, url);

});

C.

$.each(imageurls, function(i,url){

$(“<img/>”).attr(“src”, url).appendTo(“#target”); });

D.

$.each(imageurls, function(i,url){

$(“#target”).append(“<img/>”).src = url;

});

 

Correct Answer: C

Explanation:

appendTo() Method

(http://api.jquery.com/appendTo/)

jQuery.each() Function

(http://api.jquery.com/jQuery.each/)

 

 

QUESTION 38

You create a Web page that contains the following image element.

 

<img id=”myImage” src=”/image1.png” />

 

You need to write a JavaScript function that will dynamically change which image is displayed. The function must be compatible across different browsers.

 

Which code segment should you use?

 

A.

function changeImage() {

myImage.src = “image2.png”;

}

B.

function changeImage() {

document.getElementById(“myImage”).src =

“image2.png”;

}

C.

function changeImage() {

getElementById(“myImage”).src =

“image2.png”;

}

D.

function changeImage() {

window.getElementById(“myImage”).src =

“image2.png”;

}

 

Correct Answer: B

 

 

QUESTION 39

You are developing an ASP.NET Web page. You add a data-bound GridView control. The GridView contains a TemplateField that includes a DropDownList. You set the GridViews ClientIDMode property to Static, and you set the ClientIDRowSuffix property to ProductID. You need to be able to reference individual DropDownList controls from client-side script by using the ProductID. What should you set the ClientIDMode property of the DropDownList to?

 

A.

AutoID

B.

Static

C.

Inherit

D.

Predictable

 

Correct Answer: D

 

 

QUESTION 40

You create a Web page that contains the following code. (Line numbers are included for reference only.)

 

01 <script>

 

02 function changeColor(c) {

 

03 document.getElementById(“message”).style.color=c;

 

04 }

 

05 </script>

 

06

 

07 <p id=”message”>Welcome!</p>

 

08 <ul id=”color”>

 

09 <li>Black</li>

 

10 <li>Red</li>

 

11 </ul>

 

You need to ensure that when the user clicks an item in the list, the text color of the Welcome! message will change.

 

Which declaration should you use?

 

A.

<ul id=”color”>

<li onclick=”changeColor(this.innerText);”>Black</li> <li onclick=”changeColor(this.innerText);”>Red</li> </ul>

B.

<ul id=”color”>

<li onclick=”changeColor(this.style.color);”>Black</li> <li onclick=”changeColor(this.style.color);”>Red</li> </ul>

C.

<ul id=”color”>

<li><a onfocus=”changeColor(this.innerText);”>Red</a></li> <li><a onfocus=”changeColor(this.innerText);”>Black</a></li> </ul>

D.

<ul id=”color”>

<li><a onfocus=”changeColor(this.style.color);”>Red</a></li> <li><a onfocus=”changeColor(this.style.color);”>Black</a></li> </ul>

 

Correct Answer: A

 

Instant Access to Download Testing Software & PDF File for Microsoft 70-515 Real Exam

Instant Access to Try Microsoft 70-515 Free Demo

This entry was posted in 70-515 Actual Tests and tagged , , , , , . Bookmark the permalink.