Web Developer Framework 4.0 Sample Questions – 19

Question: You are developing an ASP.NET Web page. The page includes the following EntityDataSource control.
<asp:EntityDataSource ID="EntityDataSource1" runat="server"ConnectionString="name=AdventureWorksEntities"DefaultContainerName="AdventureWorksEntities" EnableFlattening="False"EntitySetName="Products" />
The page must filter the data that is displayed in a grid based on a query string parameter named ProductPrefix. The grid must display products whose ProductName starts with the query string value. You need to ensure that the page generates the appropriate database query. What should you do?

  1. Add the following element to the EntityDataSource control.
    <WhereParameters><asp:DynamicQueryStringParameter QueryStringField="ProductPrefix" Name="ProductName" /></WhereParameters>
  2. Add the following element to the EntityDataSource control.
    <WhereParameters><asp:QueryStringParameter QueryStringField="ProductPrefix" Name="ProductName" /></WhereParameters>
  3. Add the following control after the EntityDataSource control.
    <asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="EntityDataSource1"><asp:PropertyExpression Name="ProductName" /><asp:DynamicFilterExpression ControlID="ProductPrefix" /></asp:QueryExtender>
  4. Add the following control after the EntityDataSource control.
    <asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="EntityDataSource1"><asp:SearchExpression SearchType="StartsWith" DataFields="ProductName"><asp:QueryStringParameter QueryStringField="ProductPrefix" /></asp:SearchExpression> </asp:QueryExtender>

Correct Answer: 4


Question: You are developing an ASP.NET Web page that will display the median value from a sequence of integer values. You need to create an extension method to compute the median value. Which interface should you add the extension method to?

  1. IComparer<T>
  2. IEnumerable<T>
  3. IEnumerator<T>
  4. IEqualityComparer<T>

Correct Answer: 2


Question: You are developing an ASP.NET Web application. The application includes the following Entity Data Model (EDM). You instantiate an ObjectContext for the EDM named context. You need to find the total number of addresses that are associated with customers that have a non-null middle name. Which LINQ to Entities query should you use?

  1. var query = context.Customers.Where(c => c.MiddleName != null).Select(c => c.CustomerAddresses).Count();
  2. var query = context.Customers.Where(c => c.MiddleName != null).SelectMany(c => c.CustomerAddresses).Count();
  3. var query = context.Addresses.SelectMany(a => a.CustomerAddresses.OfType().Where(c => c.MiddleName != null)).Count();
  4. var query = context.Addresses.GroupBy(a => a.CustomerAddresses.Where(ca => ca.Customer.MiddleName != null)).Count();

Correct Answer: 2


Question: You are developing an ASP.NET Web service. The following code segment implements the service. (Line numbers are included for reference only.)
01[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]
02public class ProductService :System.Web.Services.WebService
03{
04[WebMethod]
05public Product GetProduct(string name)
06{
07&
08}
09
10[WebMethod]
11public Product GetProduct(int id)
12{
13 &
14}
15}
You need to ensure that both GetProduct methods can be called from a Web client. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

  1. Remove line 01.
  2. Add the static modifier on lines 05 and 11.
  3. Add the following attribute before line 10.
  4. [SoapDocumentMethod(Action=”GetProductById”)]
  5. Modify the attribute on line 10 as follows.
  6. [WebMethod(MessageName=”GetProductById”)]

Correct Answer: 1 & 4


Question: You are developing an ASP.NET Dynamic Data Web application. Boolean fields must display as Yes or No instead of as a check box. You replace the markup in the default Boolean field template with the following markup.
<asp:Label runat="server" ID="label" />
You need to implement the code that displays Yes or No. Which method of the FieldTemplateUserControl class should you override in the BooleanField class?

  1. OnLoad
  2. Construct
  3. OnDataBinding
  4. SaveControlState

Correct Answer: 3


Question: You are developing an ASP.NET MVC 2 Web application. A page makes an AJAX request and expects a list of company names in the following format.
["Adventure Works","Contoso"]
You need to write an action method that returns the response in the correct format. Which type should you return from the action method?

  1. AjaxHelper
  2. XDocument
  3. JsonResult
  4. DataContractJsonSerializer

Correct Answer: 3


Question: You are developing an ASP.NET MVC 2 Web application. The application contains a controller named Home Controller, which has an action named Index. The application also contains a separate area named Blog. A view within the Blog area must contain an Action Link that will link to the Index action of the Home Controller. You need to ensure that the Action Link in the Blog area links to the Index action of the Home Controller. Which Action Link should you use?

  1. Html.ActionLink("Home", "Index", "Home")
  2. Html.ActionLink("Home", "Index", "Home", new {area = ""}, null)
  3. Html.ActionLink("Home", "Index", "Home", new {area = "Blog"}, null)
  4. Html.ActionLink("Home", "Index", "Home", new {area = "Home"}, null)

Correct Answer:

Tagged . Bookmark the permalink.

2 Responses to Web Developer Framework 4.0 Sample Questions – 19

  1. Astra says:

    Can you explain question 3?
    In some places i have seen answer as .Select means option1 not option2

    • in Question 3 we need to find the total number of addresses that are associated with customers that have a non-null middle name. That means we need to get count of all nested collection with non-null middle name. So we use selectmany option to solve that.
      Difference between Select and SelectMany in LINQ : Select and SelectMany are projection operators. Select operator is used to select value from a collection and SelectMany operator is used to select values from a collection of collection i.e. nested collection.

Leave a Reply