PrepAway - Latest Free Exam Questions & Answers

You need to acces the EmployeeName value and display the value within the lblEmployeeName label

You are developing an ASP.Net web application.
The application includes a master page named CustomerMaster.master that contains a public string property
name EmployeeName application also includes a second master page named NestedMaster.master that is
defined by the following directive.
<%@ Master Language=”C#”
MasterPageFile=”~/CustomMaster.Master”
CodeBehind=”NestedMaster.Master.cs”
Inherits=”MyApp.NestedMaster”%>
You add a content page that uses the NestedMaster.master page file.The content page contains a label control
named lblEmployeeName.
You need to acces the EmployeeName value and display the value within the lblEmployeeName label.
What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Add the following code segment to the code-behindfile of the content page.
public void Page_load(object s, EventArgs e)
{
lblEmployeeName.text=
((MyApp.CustomMaster)Page.Master.Parent).EmployeeName;
}

B.
Add the following directive to the content page.
<%@ MasterTypeVirtualPAth=”~/CustomMaster.master” %>
Add the following code segment to the code-behind file of the content page.
public void Page_load(object s, EventArgs e)
{
lblEmployeeName.text=this.Master.EmployeeName;
}

C.
Add the following code segment to the code-behindfile of the content page.
public void Page_load(object s, EventArgs e)
{
lblEmployeeName.text=
((MyApp.CustomerMaster)Page.Master.Master).EmployeeName;
}

D.
Add the following code segment to the code-behindfile of the content page.
public void Page_load(object s, EventArgs e)
{
lblEmployeeName.text=
((MyApp.CustomerMaster)Page.Master.Master)
.FindControl(“EmployeeName”).toString();
}

3 Comments on “You need to acces the EmployeeName value and display the value within the lblEmployeeName label

  1. Jhon says:

    Page.Master.Master doesn’t work
    this example works
    String value = (((SiteMaster)Page.Master).FindControl(“mylabel”) as Label).Text;

    There’s the solution for access to the Master page without the page directive.




    0



    0

Leave a Reply