Web Developer Framework 4.0 Sample Questions – 4

Question: You are implementing a Web page that allows users to upload files to a Web server. The page includes a form that has a Submit button. You need to reject files larger than 1 MB. What should you do?

  1. Add an HTML input type= file control. Add an onSubmit handler to the form to check the file size and cancel the form submission if the file size is too large.
  2. Add an HTML input type= file control. Add an onChange handler to the input control to check the file size and cancel the upload if the file size is too large.
  3. Add an ASP.NET FileUpload control and configure it to run on the server. Add a server-side OnClick handler to the form s Submit button to save the file only if the file size is allowed.
  4. Add an ASP.NET FileUpload control and configure it to run on the server. Add a server-side OnDataBinding handler that saves the file only if the file size is allowed.

Correct Answer: 3


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

  1. 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” />
  2. 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” />
  3. For each column, create an asp:Label control and a corresponding asp:TextBox that have the same ID.
  4. For each column, create an asp:Label control and set the AssociatedControlID to the ID of the corresponding asp:Textbox control.

Correct Answer: 4


Question: You create a Web page named TestPage.aspx and a user control named TestUserControl.ascx. TestPage.aspx uses TestUserControl.ascx as shown in the following line of code. <uc:TestUserControl ID=”testControl” runat=”server”/> On TestUserControl.ascx, you need to add a read-only member named CityName to return the value “New York”. You also must add code to TestPage.aspx to read this value. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

  1. Add the following line of code to the TestUserControl.ascx.cs code-behind file. public string CityName {get { return “New York” ; } }
  2. Add the following line of code to the TestUserControl.ascx.cs code-behind file. protected readonly string CityName = “New York” ;
  3. Add the following code segment to the TestPage.aspx.cs code-behind file. protected void Page_Load(object sender, EventArgs e) {string s = testControl.CityName; }
  4. Add the following code segment to the TestPage.aspx.cs code-behind file. protected void Page_Load(object sender, EventArgs e) {string s = testControl.Attributes[“CityName”]; }

Correct Answer: 1,3


Question: You use the following declaration to add a Web user control named TestUserControl.ascx to an ASP.NET page named TestPage.aspx. <uc:TestUserControl ID=”testControl” runat=”server”/> You add the following code to the code-behind file of TestPage.aspx. private void TestMethod() {& } You define the following delegate. public delegate void MyEventHandler(); You need to add an event of type MyEventHandler named MyEvent to TestUserControl.ascx and attach the page s TestMethod method to the event. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

  1. Add the following line of code to TestUserControl.ascx.cs. public event MyEventHandler MyEvent;
  2. Add the following line of code to TestUserControl.ascx.cs. public MyEventHandler MyEvent;
  3. Replace the TestUserControl.ascx reference in TestPage.aspx with the following declaration. <uc:TestUserControl ID=”testControl” runat=”server” OnMyEvent=”TestMethod”/>
  4. Replace the TestUserControl.ascx reference in TestPage.aspx with the following declaration. <uc:TestUserControl ID=”testControl” runat=”server” MyEvent=”TestMethod”/>

Correct Answer: 1,3


Question: You create a custom server control named Task that contains the following code segment. (Line numbers are included for reference only.)
01 namespace DevControls
02 {
03 public class Task : WebControl
04 {
05 [DefaultValue(“”)]
06 public string Title { … }
07
08 protected override void RenderContents( HtmlTextWriter output)
09 {
10 output.Write(Title);
11}
12}
13}
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.)

  1. Add the following code segment to the project s AssemblyInfo.cs file. [assembly: TagPrefix(“DevControls”, “Dev”)]
  2. Replace line 05 with the following code segment. [DefaultValue(“New Task”)]
  3. Insert the following code segment immediately before line 03. [ToolboxData(“<{0}:Task runat=”server” Title=”New Task” />”)]
  4. Replace line 10 with the following code segment. output.Write(“<Dev:Task runat=”server” Title=”New Task” />” ) ;

Correct Answer: 1,3

Tagged . Bookmark the permalink.

Leave a Reply