Ensurepass

QUESTION 131

You are testing an existing ASP.NET page. The page includes a text You are able to execute malicious JavaScript code by typing it in the text box and submitting. You need to configure the page to prevent JavaScript code from being submitted by the text box. In the @ Page directive, which attribute should you set to true?

 

A.

the EnableEventValidation attribute

B.

the ResponseEncoding attribute

C.

the ValidateRequest attribute

D.

the Strict attribute

 

Correct Answer: C

 

 

QUESTION 132

You are implementing an ASP.NET page. You add asp:Button controls for Help and for Detail. You add an ASP.NET skin file named default.skin to a theme. You need to create and use a separate style for the Help button, and you must use the default style for the Detail button. What should you do?

 

A.

Add the following markup to the default.skin file.

< asp:Button ID=”Help”></ asp:Button >

< asp:Button ID=”Default”></ asp:Button >

Use the following markup for the buttons in the ASP.NET page.

< asp:Button SkinID =”Help”>Help</ asp:Button >

< asp:Button SkinID =”Default”>Detail</ asp:Button >

B.

Add the following markup to the default.skin file.

< asp:Button SkinID =”Help”></ asp:Button >

< asp:Button ID=”Default”></ asp:Button >

Use the following markup for the buttons in the ASP.NET page.

< asp:Button SkinID =”Help”>Help</ asp:Button >

< asp:Button SkinID =”Default”>Detail</ asp:Button >

C.

Add the following code segment to default.skin.

< asp:Button SkinID =”Help”></ asp:Button >

< asp:Button ></ asp:Button >

Use the following markup for the buttons in the ASP.NET page.

< asp:Button SkinID =”Help”></ asp:Button >

< asp:Button SkinID =”Default”>Detail</ asp:Button >

D.

Add the following markup to default.skin.

< asp:Button SkinID =”Help”></ asp:Button >

< asp:Button ></ asp:Button >

Use the following markup for the buttons in the ASP.NET page.

< asp:Button SkinID =”Help”>Help</ asp:Button >

< asp:Button >Detail</ asp:Button >

 

Correct Answer: D

 

 

QUESTION 133

You are implementing an ASP.NET page in an e-commerce application. Code in a btnAddToCart_Click event handler adds a product to the shopping cart. The page should check the status of the shopping cart and always show a cart icon when one or more items are in the shopping cart. The page should hide the icon when the shopping cart has no items. You need to add an event handler to implement this requirement. Which event handler should you add?

 

A.

btnAddToCart_Click

B.

Page_Load

C.

Page_PreRender

D.

Page_PreInit

 

Correct Answer: C

 

 

QUESTION 134

< font face="Arial">You are implementing a read-only page that includes the following controls.

 

clip_image002[4]

 

You disable view state to improve performance. You need to ensure that the page is updated to display the latest data when the user clicks the refresh button.

 

Which code segment should you use?

 

A.

protected void Page_PreInit(object sender, EventArgs e) {

if (!IsPostBack)

{

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

}

B.

protected void Page_Load(object sender, EventArgs e) {

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

C.

protected void gvCustomers_DataBinding(object sender, EventArgs e) {

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

D.

protected void Page_PreRender(object sender, EventArgs e) {

if (!IsPostBack)

{

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

}

 

Correct Answer: B

 

 

QUESTION 135

You are implementing an ASP.NET application that includes the following requirements. Retrieve the number of active bugs from the cache, if the number is present. If the number is not found in the cache, call a method named GetActiveBugs, and save the result under the ActiveBugs cache key. Ensure that cached data expires after 30 seconds. You need to add code to fulfill the requirements. Which code segment should you add?

 

A.

int numOfActiveBugs = (int)Cache[“ActiveBugs”]; if (!numOfActiveBugs.HasValue)

{

int result = GetActiveBugs();

Cache.Insert(“ActiveBugs”, result, null,

DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration); numOfActiveBugs = result;

}

ActiveBugs = numOfActiveBugs.Value;

B.

int numOfActiveBugs = (int) Cache.Get(“ActiveBugs”); if (numOfActiveBugs != 0)

{

int result = GetActiveBugs();

Cache.Insert(“ActiveBugs”, result, null,

DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration); numOfActiveBugs = result;

}

ActiveBugs = numOfActiveBugs;

C.

int numOfActiveBugs = 0;

if (Cache[“ActiveBugs”] == null)

{

int result = GetActiveBugs();

Cache.Add(“ActiveBugs”, result, null, DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration,

CacheItemPriority.Normal, null); Cache.NoSlidingExpiration, CacheItemPriority.Normal,

null);

numOfActiveBugs = result;

}

ActiveBugs = numOfActiveBugs;

D.

int numOfActiveBugs = (int?)Cache[“ActiveBugs”]; if (!numOfActiveBugs.HasValue)

{

int result = GetActiveBugs();

Cache.Insert(“ActiveBugs”, result, null,

Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(30)); numOfActiveBugs = result;

}

ActiveBugs = numOfActiveBugs.Value;

 

Correct Answer: A

 

 

QUESTION 136

You are developing a Web page. The user types a credit card number into an input control named cc and clicks a button named submit. The submit button sends the credit card number to the server. A JavaScript library includes a CheckCreditCard function that returns a value of true if the credit card appears to be valid, based on its checksum. You need to ensure that the form cannot be used to submit invalid credit card numbers to the server. What should you do?

 

A.

Configure the input control to run on the server. On the submit button, add a server-side OnClick handler that calls CheckCreditCard and rejects the form submission if the input is invalid.

B.

On the input control, add an onChange handler that calls CheckCreditCard and cancels the form submission when the input is invalid.

C.

Configure the input control and the submit button to run on the server. Add a submit_OnClick handler that calls CheckCreditCard and rejects the form submission if the input is invalid.

D.

On the form, add an onSubmit handler that calls CheckCreditCard and cancels the form submission if the input is invalid.

 

Correct Answer: D

 

 

QUESTION 137

You are dynamically adding controls to an ASP.NET page in the Page_Load event handler. The page will have text boxes that correspond to the columns in a database table. Each text box will be preceded by a label that displays the name of the corresponding column. You need to create the form so that when the user clicks the label, the corresponding text box is selected for input. What should you do?

 

A.

For each column, output the following HTML, where COL is replaced by the name of the column.

<label>COL</label>

<input name=”COL” type=”text” id=”COL” />

B.

For each column, output the following HTML, where COL is replaced by the name of the column.

<label AssociatedControlID=”COL”>COL</label>

<input name=”COL” type=”text” id=”COL” />

C.

For each column, create an asp:Label control and a corresponding asp:TextBox that have the same ID.

D.

For each column, create an asp:Label control and set the AssociatedControlID to the ID of the

corresponding asp:Textbox control.

 

Correct Answer: D

 

 

QUESTION 138

You create a custom server control named Task that contains the following code segment. (Line numbers are included for reference only.)

 

clip_image004[4]

 

You need to ensure that adding a Task control from the Toolbox creates markup in the following format.

 

<Dev:Task ID=”Task1″ runat=”server” Title=”New Task” />

 

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

 

A.

Add the following code segment to the project’s AssemblyInfo.cs file.

[assembly: TagPrefix(“DevControls”, “Dev”)]

B.

Replace line 05 with the following code segment.

[DefaultValue(“New Task”)]

C.

Insert the following code segment immediately before line 03. [ToolboxData(“<{0}:Task runat=”server” Title=”New Task” />”)]

D.

Replace line 10 with the following code segment. output.Write(“<Dev:Task runat=”server” Title=”New Task” />”);

 

C
orrect Answer:
AC

Explanation:

CHAPTER 7 Creating Custom Web Controls

Lesson 2: Creating Custom Web Server Controls

Controlling the Markup Generated for Your Custom Web Server Control (page 369)

 

 

QUESTION 139

You create an ASP.NET page that contains the following tag.

 

<h1 id=”hdr1″ runat=”server”>Page Name</h1>

 

You need to write code that will change the contents of the tag dynamically when the page is loaded. What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

 

A.

this.hdr1.InnerHtml = “Text”;

B.

(hdr1.Parent as HtmlGenericControl).InnerText = “Text”;

C.

HtmlGenericControl h1 =

this.FindControl(“hdr1”) as HtmlGenericControl;

h1.InnerText = “Text”;

D.

HtmlGenericCont
rol h1 =

Parent.FindControl(“hdr1”) as HtmlGenericControl; h1.InnerText = “Text”;

 

Correct Answer: AC

 

 

QUESTION 140

You are implementing an ASP.NET application that makes extensive use of JavaScript libraries. Not all pages use all scripts, and some scripts depend on other scripts. When these libraries load sequentially, some of your pages load too slowly. You need to use the ASP.NET Ajax Library Script Loader to load these scripts in parallel. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

 

A.

In your site’s master page, add a call to Sys.loader.defineScripts to define each of the scripts that are used in the site.

B.

In your site’s master page, add a call to Sys.loader.registerScript to define each of the scripts that are used in the site.

C.

In each page that users scripts, add a call to Sys.get for each script that is needed in that page.

D.

In each page that users scripts, add a call to Sys.require for each script that is needed in that page.

 

Correct Answer: AD

Explanation:

The ASP.NET Ajax Library’s Script Loader provides a flexible way to load scripts required by a page as well as any dependencies that may be needed. Because it loads scripts in parallel the page’s load time is minimized and the amount of code needed to load scripts, th
eir dependencies and components is significantly reduced. To load ASP.NET Ajax Library or jQuery scripts a collection called Sys.scripts (defined in the ASP.NET Ajax Library’s Start.js file) can be used along with a call to Sys.require. In cases where a custom script has dependencies on one or more scripts a custom metadata file can be created to define the dependencies. This metadata file can define all the scripts involved using the Script Loader’s Sys.loader.defineScripts function. The metadata script defines the custom scripts to load as well as any dependencies they may have.

HOW TO Load Required Scripts

(http://www.asp.net/ajaxLibrary/HOW%20TO%20Load%20Required%20Scripts.ashx) HOW TO Load a Custom Script with Dependencies

(http://www.asp.net/ajaxlibrary/HOW%20TO%20Load%20a%20Custom%20Script%20with %20Dependencies.ashx)

 

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

Instant Access to Try Microsoft 70-515 Free Demo

Comments are closed.