Exam 70-562 : Microsoft .NET Framework 3.5, ASP.NET Application Development – 33

Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application that uses Microsoft ASP.NET 3.5. You decide to enable view state on all pages in the application. During routine monitoring you discover that certain pages contain large amounts of information that travel between the Web server and the client’s browser. You decide to modify the application in order to store view state in a databas

  • What should you do? (Choose all that apply)
    1. You should consider defining a control adapter in a browser definition file of the App_Browsers folder.
    2. You should consider setting the historySize attribute of the sessionPageState element to 0 in the Web.config fil
    3. You should consider setting the enableViewState feature of the pages element to false in the Web.config fil
    4. You should implement a class that derives from PageAdapter. Then you need to override the GetStatePersister metho
    5. You should consider setting the enableViewStateMac feature of the pages element to true in the Web.config fil

    Correct Answer: 1,4


    Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application that uses Microsoft ASP.NET 3.5. A page in the Web application will permit clients to dynamically configure its layout. Clients are able to add user controls to the page dynamically by clicking a Button control on the pag

  • The following code exists for the page:
    public partial class PortalPage : System.Web.UI.Page
    {
    private int _sectionCount = 0;
    protected void AddButton_Click(object sender, EventArgs e)
    {
    Control control = this.Load("Section.ascx");
    Controls.Add(control);
    _sectionCount++;
    }
    } 

    You receive an instruction from the CIO to make sure that the page retains the dynamically-added user controls as it undergoes post-back requests. You need to ensure that the solution does not permit a configuration change in order to override this functionality. What should you do? (Choose all that apply)

    1. You should use the code segment:
      protected override LoadViewState(object savedState)
      {
      _sectionCount = (int)savedState;
      }
    2. You should use the code segment:
      protected override object SaveViewState()
      {
      ViewState[“SectionCount”] = _sectionCount;
      }
    3. You should use the code segment:
      protected override void LoadControlState(object savedState)
      {
      Pair pair = (Pair)savedState;
      base.LoadControlState(pair.First);
      _sectionCount = (int)pair.Second;
      for (int index = 0; index < _sectionCount; index++)
      {
      Control control = this.LoadControl(“Section.ascx”);
      Controls.Add(control);
      }
      }
    4. You should use the code segment:
      protected override object SaveControlState()
      {
      Pair pair = new Pair();
      pair.First = base.SaveControlState();
      pair.Second = _sectionCount;
      return pair;
      }
    5. You should use the code segment:
      protected override void OnInit(EventArgs e)
      {
      Page.RegisterRequiresControlState(this);
      base.OnInit(e);
      }

    Correct Answer: 3,4,5


    Question: You work as a Web Application Developer. You are in the process of creating an ASP.NET application that uses Microsoft .NET Framework 3.5. You decide to create a custom Web user control for the application. You name this control TestShar

  • TestShare will be compiled as a library. The code below is written for TestShar
  • (The line numbers is included for reference purposes)
    1 Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
    2 MyBase.OnInit(e)
    3
    4 End Sub
    The master pages in the application contain the directive below:

    <%@ Master Language="VB" EnableViewState="false" %> 

    You receive an instruction from management to make sure that the state of TestShare is accessible on the subsequent pages that reference a master pag

  • You thus need to determine the appropriate code that should be added at line 3. What should you identify?
    1. You should consider adding Page.RegisterRequiresControlState(Me).
    2. You should consider adding Page.UnregisterRequiresControlState(Me).
    3. You should consider adding Page.RegisterStartupScript(“TestShare”, “server”).
    4. You should consider adding Page.RegisterRequiresPostBack(Me).

    Correct Answer: 1


    Question: You work as a Web Application Developer at Company.com. You make use of Microsoft .NET Framework 3.5 to create an ASP.NET application. Your application contains a class with the code below:

    public object GetAllOrders(sqlConnection cnn) {
    if (Cache["orders"] == null) {
    SqlCommand cmd = new SqlCommand("SELECT * FROM Orders", cnn);
    cnn.Open();
    Cache.Insert("orders", GetData(cmd));
    cnn.Close();
    }
    return Cache["orders"];
    }
    public object GetOrderData(SqlCommand ordCmd) {
    // insert code here
    } 

    You notice that the GetAllOrders method is called to provide this list from the Cache object every time a Web form has to access a list of products. To ensure productivity management wants you to make sure that there is always a list of products available in the Cache object. What should you do?

    1. Your best choice would be to add the code:
      public object GetOrderData(SqlCommand ordCmd) {
      return ordCmd.ExecuteReader();
      SqlDataReader datareader;
      ordCmd.CommandTimeout = int.MaxValue;
      }
    2. Your best choice would be to add the code:
      public object GetOrderData(SqlCommand ordCmd) {
      datareader = ordCmd.ExecuteReader();
      return datareader;
      }
    3. Your best choice would be to add the code:
      public object GetOrderData(SqlCommand ordCmd) {
      SqlDataAdapter dadtp = new SqlDataAdapter();
      dadtp.SelectCommand = ordCmd;
      DataSet dset = new DataSet();
      return dset.Tables[0];
      }
    4. Your best choice would be to add the code:
      public object GetOrderData(SqlCommand ordCmd) {
      SqlDataAdapter dadtp = new SqlDataAdapter(ordCmd);
      DataSet dset = new DataSet();
      dadtp.Fill(dset);
      return dset;
      }

    Correct Answer: 4


    Question: You work as a Web Application Developer. You are in the process of creating an ASP.NET AJAX enabled application. In order to create the application you make use of Microsoft .NET Framework 3.5. You want to configure the SessionState for the application to run on a Web farm. How can this be accomplished?

    1. This can be accomplished adding the code:
      <sessionState mode=”SQLServer” cookieless=”false” sqlConnectionString=”Integrated” Security=SSPI; data source=MySqlServer;”/>.
    2. This can be accomplished adding the code:
      <sessionState mode=”InProc” cookieless=”UseDeviceProfile”/>.
    3. This can be accomplished adding the code:
      <sessionState mode=”InProc” cookieless=”UseCookies”/>.
    4. This can be accomplished adding the code:
      <sessionState mode=”SQLServer” cookieless=”UseUri” sqlConnectionString=”Integrated” Security=SSPI; data source=SQL Server;”/>.

    Correct Answer: 1

  • Tagged . Bookmark the permalink.

    Leave a Reply