Ensurepass

QUESTION 161

You are developing an ASP.NET Web application. The application will contain a page that is customized for various browsers. The application will use output caching to optimize performance. You need to ensure that the page is cached by browser type and major version only. Which attribute should you add to the OutputCache directive?

 

A.

VaryByCustom=”browser”

B.

VaryByCustom=”User-Agent”

C.

VaryByHeader=”browser”

D.

VaryByHeader=”User-Agent”

 

Correct Answer: A

 

 

QUESTION 162

You are developing an ASP.NET Web page that includes a text box control. The page includes a server-side method named ValidateValue. You need to configure the page so that the text box value is validated by using the ValidateValue method. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

 

A.

Use the CompareValidator control.

B.

Use the CustomValidator control.

C.

Set ValidationGroup on the control to ValidateValue.

D.

Set OnServerValidate on the control to ValidateValue.

 

Correct Answer: BD

 

 

QUESTION 163

You are implementing an ASP.NET Web site. The site allows users to explicitly choose the display language for the site’s Web pages. You create a Web page that contains a DropDownList named ddlLanguage, as shown in the following code segment.

 

<asp:DropDownList ID=”ddlLanguage” runat=”server” AutoPostBack=”True” ClientIDMode=”Static”OnSelectedIndexChanged=”SelectedLanguageChanged”>

 

<asp:ListItem Value=”en”>English</asp:ListItem>

 

<asp:ListItem Value=”es”>Spanish</asp:ListItem>

 

<asp:ListItem Value=”fr”>French</asp:ListItem>

 

<asp:ListItem Value=”de”>German</asp:ListItem>

 

</asp:DropDownList>

 

The site contains localized resources for all page content that must be translated into the language that is selected by the user.

 

You need to add code to ensure that the page displays content in the selected language if the user selects a language in the drop-down list.

 

Which code segment should you use?

 

A.

protected void SelectedLanguageChanged(object sender, EventArgs e) {

Page.UICulture = ddlLanguage.SelectedValue;

}

B.

protected override void InitializeCulture()

{

Page.UICulture = Request.Form[“ddlLanguage”];

}

C.

protected void Page_Load(object sender, EventArgs e) {

Page.Culture = Request.Form[“ddlLanguage”];

}

D.

protected override void InitializeCulture()

{

Page.Culture = ddlLanguage.SelectedValue;

}

 

Correct Answer: B

 

 

QUESTION 164

You are implementing a method in an ASP.NET application that includes the following requirements. Store the number of active bugs in the cache. The value should remain in the cache when there are calls more often than every 15 seconds. The value should be removed from the cache after 60 seconds. You need to add code to meet the requirements. Which code segment should you add?

 

A.

Cache.Insert(“ActiveBugs”, result, null, DateTime.Now.AddSeconds(60), TimeSpan.

FromSeconds(15));

B.

Cache.Insert(“Trigger”, DateTime.Now, null, DateTime.Now.AddSeconds(60), Cache.

NoSlidingExpiration);

CacheDependency cd = new CacheDependency(null, new string[] { “Trigger” });

Cache.Insert(“ActiveBugs”, result, cd, Cache.NoAbsoluteExpiration, TimeSpan.

FromSeconds(15));

C.

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

FromSeconds(15));

CacheDependency cd = new CacheDependency(null, new string[] { “ActiveBugs” });

Cache.Insert(“Trigger”, DateTime.Now, cd, DateTime.Now.AddSeconds(60), Cache.

NoSlidingExpiration);

D.

CacheDependency cd = new CacheDependency(null, new string[] { “Trigger” });

Cache.Insert(“Trigger”, DateTime.Now, null, DateTime.Now.AddSeconds(60), Cache.

NoSlidingExpiration);

Cache.Insert(“ActiveBugs”, result, cd, Cache.NoAbsoluteExpiration, TimeSpan.

FromSeconds(15));

 

Correct Answer: B

 

 

QUESTION 165

You are implementing a method in an ASP.NET application that includes the following requirements. Store the number of active bugs in the cache. The value should remain in the cache when there are calls more often than every 15 seconds. The value should be removed from the cache after 60 seconds. You need to add code to meet the requirements. Which code segment should you add?

 

A.

Cache.Insert(“ActiveBugs”, result, Nothing, DateTime.Now.AddSeconds(60), TimeSpan.FromSeconds(15))

B.

Cache.Insert(“Trigger”, DateTime.Now, NothingDateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration) Dim cd As CacheDependency = New CacheDependency(Nothing,

New String() {“Trigger”})

Cache.Insert(“ActiveBugs”, result, cd, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(15))

C.

Cache.Insert(“ActiveBugs”, result, Nothing, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(15))

Dim cd As CacheDependency = New CacheDependency(Nothing, New String() {“ActiveBugs”})

Cache.Insert(“Trigger”, DateTime.Now, cd, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration)

D.

Dim cd As CacheDependency = New CacheDependency(Nothing, New String() {“Trigger”})

Cache.Insert(“Trigger”, DateTime.Now, Nothing,

DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration) Cache.Insert(“ActiveBugs”, result, cd, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(15))

 

Correct Answer: B

 

 

QUESTION 166

You are implementing an ASP.NET application that will use session state in out-of-proc mode. You add the following code.

 

public class Person

 

{

 

public string FirstName { get; set;}

 

public string LastName { get; set;}

 

}

 

You need to add an attribute to the Person class to ensure that you can save an instance to session state.

 

Which attribute should you use?

 

A.

Bindable

B.

DataObject

C.

Serializable

D.

DataContract

 

Correct Answer: C

 

 

QUESTION 167

You are implementing an ASP.NET application that will use session state in out-of-proc mode. You add the following code.

 

Public Class Person

 

Public Property FirstName As String

 

Public Property LastName As String

 

End Class

 

You need to add an attribute to the Person class to ensure that you can save an instance to session state. Which attribute should you use?

 

A.

Bindable

B.

Serializable

C.

DataContract

D.

DataObject

 

Correct Answer: B

 

 

QUESTION 168

You create a Web page named TestPage.aspx and a user control named contained in a file named TestUserControl.ascx. You need to dynamically add TestUserControl.ascx to TestPage.aspx. Which code segment should you use?

 

A.

protected void Page_Load(object sender, EventArgs e) {

Control userControl = Page.LoadControl(“TestUserControl.ascx”); Page.Form.Controls.Add(userControl);

}

B.

protected void Page_Load(object sender, EventArgs e) {

Control userControl = Page.FindControl(“TestUserControl.ascx”); Page.Form.Controls.Load(userControl);

}

C.

protected void Page_PreInit(object sender, EventArgs e) {

Control userControl = Page.LoadControl(“TestUserControl.ascx”); Page.Form.Controls.Add(userControl);

}

D.

protected void Page_PreInit(object sender, EventArgs e) {

Control userControl = Page.FindControl(“TestUserControl.ascx”); Page.Form.Controls.Load(userControl);

}

 

Correct Answer: C

Explanation:

Dynamic controls should be added in preinit event for them to participate in view state. Check description of preinit and init events on page-105 of Microsoft Press book MCTS 70- 515.

Exam collection says

C.Page_PreInit

 

 

QUESTION 169

You need to dynamically add TestUserControl.ascx to TestPage.aspx. Which code segment should you use?

 

A.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim userControl As Control = Page.LoadControl(“TestUserControl.ascx”) Page.Form.Controls.Add(userControl)

End Sub

B.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

Handles Me.Load

Dim userControl As Control = Page.FindControl(“TestUserControl.ascx”) Page.Form.Controls.Add(userControl)

End Sub

C.

Private Sub TestPage_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

Dim userControl As Control = Page.LoadControl(“TestUserControl.ascx”) Page.Form.Controls.Add(userControl)

End Sub

D.

Private Sub TestPage_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit

Dim userControl As Control =

Page.FindControl(“TestUserControl.ascx”Page.Form.Controls.Add(userControl) End Sub

 

Correct Answer: C

Explanation:

Dynamic controls should be added in preinit event for them to participate in view state. Check description of preinit and init events on page-105 of Microsoft Press book MCTS 70-515.

 

 

QUESTION 170

You are implementing an ASP.NET page that includes the following down list.

 

clip_image001

 

You need to dynamically add values to the end of the drop-down list.

 

What should you do?

 

A.

Add the following OnPreRender event handler to the asp:DropDownList protected void MyDropDown_PreRender(object sender, EventArgs e) {

DropDownList ddl = sender as DropDownList;

Label lbl = new Label();

lbl.Text = “Option”;

lbl.ID = “Option”;

ddl.Controls.Add(lbl);

}

B.

Add the following OnPreRender event handler to the asp:DropDownList protected void MyDropDown_PreRender(object sender, EventArgs e) {

DropDownList ddl = sender as DropDownList;

ddl.Items.Add(“Option”);

}

C.

Add the following event handler to the page code-behind. protected void Page_LoadComplete(object sender, EventArgs e) {

DropDownList ddl = Page.FindControl(“MyDropDown”) as DropDownList; Label lbl = new Label();

lbl.Text = “Option”;

lbl.ID = “Option”;

ddl.Controls.Add(lbl);

}

D.

Add the following event handler to the page code-behind. protected void Page_LoadComplete(object sender, EventArgs e) {

DropDownList ddl = Page.FindControl(“MyDropDown”) as DropDownList; ddl.Items.Add(“Option”);

}

 

Correct Answer: B

 

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.