PrepAway - Latest Free Exam Questions & Answers

Author: seenagape

Which line of code should you identify?

You are creating a Web Part for SharePoint Server 2010.

The Web Part contains the following code segment. (Line numbers are included for reference only.)

01 protected override void CreateChildControls()
02 {
03 base.CreateChildControls();
04 SPSecurity.RunWithElevatedPrivileges(
05 delegate()
06 {
07 Label ListCount = new Label();
08 ListCount.Text = String.Format(“There are {0} Lists”, SPContext.Current.Web.Lists.Count);
09 Controls.Add(ListCount);
10 });
11 }

You need to identify which line of code prevents the Web Part from being deployed as a sandboxed solution.

Which line of code should you identify?

Which code segment you should insert at line 12?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.

You create a Web form that contains the following code fragment.

<asp:TextBox runat=”server” ID=”txtSearch” />
<asp:Button runat=”server” ID=”btnSearch” Text=”Search”
OnClick=”btnSearch_Click” />
<asp:GridView runat=”server” ID=”gridCities” />

You write the following code segment in the code-behind file. (Line numbers are included
for reference only.)

01 protected void Page_Load(object sender, EventArgs e)
02 {
03 DataSet objDS = new DataSet();
04 SqlDataAdapter objDA = new SqlDataAdapter(objCmd);
05 objDA.Fill(objDS);
06 gridCities.DataSource = objDs;
07 gridCities.DataBind();
08 Session[“ds”] = objDS;
09 }
10 protected void btnSearch_Click(object sender, EventArgs e)
11 {
12
13 }

You need to ensure that when the btnSearch Button control is clicked, the records in
the gridCities GridView control are filtered by using the value of the txtSearch TextBox.

Which code segment you should insert at line 12?

What should you do?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft
ADO.NET. The application uses a Microsoft SQL Server 2005 database. To open a
connection to the database, you write the following code segment. (Line numbers are
included
for reference only.)
01 private void GetOpenOrders() {
02 try {
03 //open SqlConnection and execute command.
04 }
05 catch (SqlException exp) {
06
07 }
08 }
The connection generates error messages and raises an exception. You use a ListBox control
named lstResults to display the error messages.You need to add a list item in the lstResults
control for each connection-related error message returned by the SqlConnection object.
What should you do?

What should you do?

You create an application by using Microsoft Visual Studio .NET 2008 and the .NET Framework 3.5. Users access the application by using Windows-based client applications or Web-based client applications. All client applications share common business logic to handle transaction processing requests. You need to ensure that the application is easy to maintain. What should you do?

What should you do?

You create a console application to manage Personal Sites.
The application contains the following code segment. (Line numbers are included for reference only.)

01 SPSite siteCollection = new SPSite(“http://moss”);
02 UserProfileManager profileManager = new UserProfileManager(ServerContext.GetContext(siteCollection));
03 UserProfile profile = profileManager.GetUserProfile(“domain\\username”);
04 SPSite personalSite = profile.PersonalSite;
05
06 siteCollection.Dispose();

You deploy the application to a SharePoint site.

After deploying the application, users report that the site loads slowly. You need to modify the application to prevent the site from loading slowly.

What should you do?

Which code segment should you use?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.

You create a Web page named enterName.aspx.
The Web page contains a TextBox control named txtName.
The Web page cross posts to a page named displayName.aspx that contains a Label control named lblName.
You need to ensure that the lblName Label control displays the text that was entered in the txtName TextBox control.

Which code segment should you use?

What should you do?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework
version 3.5.You add a Web page named HomePage.aspx in the application. The Web page
contains different controls.You add a newly created custom control named CachedControl to
the Web page. You need to ensure that the following requirements are met:
The custom control state remains static for one minute.
The custom control settings do not affect the cache settings of other elements in the Web page.
What should you do?

What should you do?

You create an application by using Microsoft Visual Studio .NET 2008 and the .NET Framework 3.5. The component will return custom business objects. You plan to develop a design strategy that meets the following requirements:

The component can be accessed by the .NET Windows applications and JavaScript-based Web applications. The component can be consumed by the client applications by using the minimum amount of code. The least amount of network bandwidth is consumed. You need to implement the design strategy by using the minimum amount of development effort. What should you do?

Which object should you dispose of?

You create an event receiver.

The ItemAdded method for the event receiver contains the following code segment. (Line numbers are included for reference only.)

01 SPWeb recWeb = properties.Web;
02 using (SPSite siteCollection = new SPSite(“http://site1/hr”))
03 {
04 using (SPWeb web = siteCollection.OpenWeb())
05 {
06 PublishingWeb oWeb = PublishingWeb.GetPublishingWeb(web);
07 PublishingWebCollection pubWebs = oWeb.GetPublishingWebs();
08 foreach (PublishingWeb iWeb in pubWebs)
09 {
10 try
11 {
12 SPFile page = web.GetFile(“/Pages/default.aspx”);
13 SPLimitedWebPartManager wpManager = page.GetLimitedWebPartManager(PersonalizationScope.Shared);
14 }
15 finally
16 {
17 if (iWeb != null)
18 {
19 iWeb.Close();
20 }
21 }
22 }
23 }
24 }

You need to prevent the event receiver from causing memory leaks.

Which object should you dispose of?

What should you do?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.

You write the following code segment to create a client-script function. (Line numbers are included for reference only.)

01 function updateLabelControl(labelId, newText) {
02 var label = $find(labelId);
03 label.innerHTML = newText;
04 }

The client script function uses ASP.NET AJAX and updates the text of any Label control in the Web form.

When you test the client script function, you discover that the Label controls are not updated. You receive the following JavaScript error message in the browser: “‘null’ is null or not an object.”

You need to resolve the error.

What should you do?