Web Developer Framework 4.0 Sample Questions – 17

Question: You are developing an ASP.NET templated server control. You need to ensure that a new ID namespace is created within the page control hierarchy when the control is added to a page. Which interface should you implement on the control?

  1. IDataItemContainer
  2. INamingContainer
  3. IDataKeysControl
  4. IExtenderControl

Correct Answer: 2


Question: You are developing an ASP.NET Web page. The page contains the following markup.
<asp:GridView ID="gvModels" runat="server" onrowdatabound="gvModels_RowDataBound" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Model" />
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="img" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

The page s code-behind file includes the following code segment. (Line numbers are included for reference only.)
01protected void gvModels_RowDataBound(object sender,GridViewRowEventArgs e)
02{
03if (e.Row.RowType == DataControlRowType.DataRow)
04{
05CarModel cm = (CarModel)e.Row.DataItem;
06
07img.ImageUrl = String.Format(“images/{0}.jpg”,cm.ID);
08&
09}
10}
You need to get a reference to the Image named img. Which code segment should you add at line 06?

  1. Image img = (Image)Page.FindControl(“img”);
  2. Image img = (Image)e.Row.FindControl(“img”);
  3. Image img = (Image)gvModels.FindControl(“img”);
  4. Image img = (Image)Page.Form.FindControl(“img”);

Correct Answer: 2


Question: 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?

  1. <%: Model.FirstName %>
  2. <%= Model.FirstName %>
  3. <% Response.Write(Model.FirstName); %>
  4. <% Response.Write(HttpUtility.HtmlDecode(Model.FirstName)); %>

Correct Answer: 1


Question: 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 GridView s 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?

  1. AutoID
  2. Static
  3. Inherit
  4. Predictable

Correct Answer: 4


Question: You are developing an ASP.NET Web page. The page includes a DropDownList control. You need to call a client-side function when the user changes the value of the control. Which event should you handle?

  1. Click
  2. SelectedIndexChanged
  3. Change
  4. Select

Correct Answer: C

Tagged . Bookmark the permalink.

Leave a Reply