Web Developer Framework 4.0 Sample Questions – 2

Question: You are implementing an ASP.NET Web site that will be accessed by an international audience. The site contains global and local resources for display elements that must be translated into the language that is selected by the user. You need to ensure that the Label control named lblCompany displays text in the user s selected language from the global resource file. Which control markup should you use?

  1. <asp:Label ID="lblCompany" runat="server" meta:resourcekey="lblCompany" />
  2. <asp:Label ID="lblCompany" runat="server" Text="meta:lblCompany.Text" />
  3. <asp:Label ID="lblCompany" runat="server"Text="<%$ Resources:lblCompanyText %>" />
  4. <asp:Label ID="lblCompany" runat="server"Text="<%$ Resources:WebResources, lblCompanyText %>" />

Correct Answer: 4


Question: You are implementing an ASP.NET page in an e-commerce application. Code in a btnAddToCart_Click event handler adds a product to the shopping cart. The page should check the status of the shopping cart and always show a cart icon when one or more items are in the shopping cart. The page should hide the icon when the shopping cart has no items. You need to add an event handler to implement this requirement. Which event handler should you add?

  1. btnAddToCart_Click
  2. Page_Load
  3. Page_PreRender
  4. Page_PreInit

Correct Answer: 3


Question: You are implementing a read-only page that includes the following controls. <asp:Button ID=”btnRefresh” runat=”server” Text=”Button” /> <asp:GridView ID=”gvCustomers” runat=”server” EnableViewState=”False” OnDataBinding=”gvCustomers_DataBinding”> </asp:GridView> You disable view state to improve performance. You need to ensure that the page is updated to display the latest data when the user clicks the refresh button. Which code segment should you use?

  1. protected void Page_PreInit(object sender, EventArgs e)
    {if (!IsPostBack){gvCustomers.DataSource = GetCustomers();gvCustomers.DataBind();} }
  2. protected void Page_Load(object sender, EventArgs e)
    {gvCustomers.DataSource = GetCustomers();gvCustomers.DataBind(); }
  3. protected void gvCustomers_DataBinding(object sender, EventArgs e)
    {gvCustomers.DataSource = GetCustomers();gvCustomers.DataBind(); }
  4. protected void Page_PreRender(object sender, EventArgs e)
    {if (!IsPostBack){gvCustomers.DataSource = GetCustomers();gvCustomers.DataBind();} }

Correct Answer: 2


Question: You create an ASP.NET page named TestPage.aspx that contains validation controls. You need to verify that all input values submitted by the user have been validated by testing the Page.IsValid property. Which page event should you add an event handler to?

  1. Init
  2. Load
  3. PreInit
  4. PreLoad

Correct Answer: 2


Question: You are implementing an ASP.NET application that includes the following requirements. Retrieve the number of active bugs from the cache, if the number is present. If the number is not found in the cache, call a method named GetActiveBugs, and save the result under the ActiveBugs cache key. Ensure that cached data expires after 30 seconds. You need to add code to fulfill the requirements. Which code segment should you add?

  1. int? numOfActiveBugs = (int)Cache["ActiveBugs"];
    if (!numOfActiveBugs.HasValue)
    {
    int result = GetActiveBugs();
    Cache.Insert("ActiveBugs", result, null,DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration);
    numOfActiveBugs = result;
    }
  2. ActiveBugs = numOfActiveBugs.Value;
    int numOfActiveBugs = (int) Cache.Get("ActiveBugs");
    if (numOfActiveBugs != 0)
    {
    int result = GetActiveBugs();
    Cache.Insert("ActiveBugs", result, null,DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration);
    numOfActiveBugs = result;
    }
  3. ActiveBugs = numOfActiveBugs;
    int numOfActiveBugs = 0;
    if (Cache["ActiveBugs"] == null)
    {
    int result = GetActiveBugs();
    Cache.Add("ActiveBugs", result, null, DateTime.Now.AddSeconds(30),Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
    numOfActiveBugs = result;
    }
  4. ActiveBugs = numOfActiveBugs;
    int? numOfActiveBugs = (int)Cache["ActiveBugs"];
    if (!numOfActiveBugs.HasValue)
    {
    int result = GetActiveBugs();
    Cache.Insert("ActiveBugs", result, null,Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(30));
    numOfActiveBugs = result;
    }
    ActiveBugs = numOfActiveBugs.Value;

Correct Answer: 1

Tagged . Bookmark the permalink.

4 Responses to Web Developer Framework 4.0 Sample Questions – 2

  1. Fadill says:

    You have post around 35 questions, could you please tell me how many question will be there for the MCTS (Exam 70-515).
    If it is more than 35 can you please send me the rest
    Thanks
    Fadill

    • Hi Fadill,
      I have submitted approx 200 sample question from various dumps and posted into my blog pages. Kindly check this Category
      URL: http://planetofcoders.com/category/certifications/
      In this URL there are lots of Certifications Study material available. Now kindly search all posts starts with “Web Developer Framework 4.0 Sample Questions – ” then you will find there are lots of posts it approx 35 posts and ever post has minimum 5 questions. I hole they will definitely helps you a lot……

  2. miu shun says:

    I Have a Q. on Q. 5.
    The HasValue only works with nullable types, is numOfActiveBugs nullable ??
    int numOfActiveBugs = (int)Cache[“ActiveBugs”];
    urs,
    Miu.

    • Hi Miu,
      Yes you are right, I did a mistake and forgot numOfActiveBugs variable to make it nullable. But now I did corrected this in my post. Thanks for finding an error in my post.
      Keep reading and If you found any error please intimate me.
      Thanks,
      Gaurav Agrawal

Leave a Reply