1. Question: You create a Web page named TestPage.aspx and a user control named contained in a file named TestUserControl.ascx. You need to dynamically add TestUserControl.ascx to TestPage.aspx. Which code segment should you use?

    A
    protected void Page_Load(object sender, EventArgs e) { Control userControl = Page.LoadControl("TestUserControl.ascx"); Page.Form.Controls.Add(userControl); }

    B
    protected void Page_Load(object sender, EventArgs e) { Control userControl = Page.FindControl("TestUserControl.ascx"); Page.Form.Controls.Load(userControl); }

    C
    protected void Page_PreInit(object sender, EventArgs e) { Control userControl = Page.LoadControl("TestUserControl.ascx"); Page.Form.Controls.Add(userControl); }

    D
    protected void Page_PreInit(object sender, EventArgs e) { Control userControl = Page.FindControl("TestUserControl.ascx"); Page.Form.Controls.Load(userControl); }

    Note: Not available
    1. Report
  2. 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.)

    A
    Add the following line of code to the TestUserControl.ascx.cs code-behind file. public string CityName { get { return "New York"; } }

    B
    Add the following line of code to the TestUserControl.ascx.cs code-behind file. protected readonly string CityName = "New York";

    C
    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; }

    D
    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"]; }

    Note: Not available
    1. Report
  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.)

    A
    Add the following line of code to TestUserControl.ascx.cs. public event MyEventHandler MyEvent;

    B
    Add the following line of code to TestUserControl.ascx.cs. public MyEventHandler MyEvent;

    C
    Replace the TestUserControl.ascx reference in TestPage.aspx with the following declaration. <uc:TestUserControl ID="testControl" runat="server" OnMyEvent="TestMethod"/>

    D
    Replace the TestUserControl.ascx reference in TestPage.aspx with the following declaration. <uc:TestUserControl ID="testControl" runat="server" MyEvent="TestMethod"/>

    Note: Not available
    1. Report
  4. 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.)

    A
    Add the following code segment to the project's AssemblyInfo.cs file. [assembly: TagPrefix("DevControls", "Dev")]

    B
    Replace line 05 with the following code segment. [DefaultValue("New Task")]

    C
    Insert the following code segment immediately before line 03. [ToolboxData("<{0}:Task runat=\"server\" Title=\"New Task\" />")]

    D
    Replace line 10 with the following code segment. output.Write("<Dev:Task runat=\"server\" Title=\"New Task\" />");

    Note: Not available
    1. Report
  5. Question: You are implementing an ASP.NET page that includes the following drop-down list. <asp:PlaceHolder ID="dynamicControls" runat="server"> <asp:DropDownList ID="MyDropDown" runat="server"> <asp:ListItem Text="abc" value="abc" /> <asp:ListItem Text="def" value="def" /> </asp:DropDownList> </asp:PlaceHolder> You need to dynamically add values to the end of the drop-down list. What should you do?

    A
    Add the following OnPreRender event handler to the asp:DropDownList protected void MyDropDown_PreRender(object sender, EventArgs e) { DropDownList ddl = sender as DropDownList; Label lbl = new Label(); lbl.Text = "Option"; lbl.ID = "Option"; ddl.Controls.Add(lbl); }

    B
    Add the following OnPreRender event handler to the asp:DropDownList protected void MyDropDown_PreRender(object sender, EventArgs e) { DropDownList ddl = sender as DropDownList; ddl.Items.Add("Option"); }

    C
    Add the following event handler to the page code-behind. protected void Page_LoadComplete(object sender, EventArgs e) { DropDownList ddl = Page.FindControl("MyDropDown") as DropDownList; Label lbl = new Label(); lbl.Text = "Option"; lbl.ID = "Option"; ddl.Controls.Add(lbl); }

    D
    Add the following event handler to the page code-behind. protected void Page_LoadComplete(object sender, EventArgs e) { DropDownList ddl = Page.FindControl("MyDropDown") as DropDownList; ddl.Items.Add("Option"); }

    Note: Not available
    1. Report
  6. Question: You create an ASP.NET page that contains the following tag. <h1 id="hdr1" runat="server">Page Name</h1> You need to write code that will change the contents of the tag dynamically when the page is loaded. What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

    A
    this.hdr1.InnerHtml = "Text";

    B
    (hdr1.Parent as HtmlGenericControl).InnerText = "Text";

    C
    HtmlGenericControl h1 = this.FindControl("hdr1") as HtmlGenericControl; h1.InnerText = "Text";

    D
    HtmlGenericControl h1 = Parent.FindControl("hdr1") as HtmlGenericControl; h1.InnerText = "Text";

    Note: Not available
    1. Report
  7. Question: You are implementing custom ASP.NET server controls. You have a base class named RotaryGaugeControl and two subclasses named CompassGaugeControl and SpeedGaugeControl. Each control requires its own client JavaScript code in order to function properly. The JavaScript includes functions that are used to create the proper HTML elements for the control. You need to ensure that the JavaScript for each of these controls that is used in an ASP.NET page is included in the generated HTML page only once, even if the ASP.NET page uses multiple instances of the given control. What should you do?

    A
    Place the JavaScript in a file named controls.js and add the following code line to the Page_Load method of each control. Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "script", "controls.js");

    B
    Add the following code line to the Page_Load method of each control, where strJavascript contains the JavaScript code for the control. Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", strJavascript);

    C
    Add the following code line to the Page_Load method of each control, where CLASSNAME is the name of the control class and strJavascript contains the JavaScript code for the control. Page.ClientScript.RegisterStartupScript(typeof(CLASSNAME), "script", strJavascript);

    D
    Add the following code line to the Page_Load method of each control, where CLASSNAME is the name of the control class and strJavascript contains the JavaScript code for the control. Page.ClientScript.RegisterClientScriptBlock(typeof(CLASSNAME), "script", strJavascript);

    Note: Not available
    1. Report
  8. Question: You are creating an ASP.NET Web site. The site is configured to use Membership and Role management providers. You need to check whether the currently logged-on user is a member of a role named Administrators. Which code segment should you use?

    A
    bool isMember = Roles.GetUsersInRole("Administrators").Any();

    B
    bool isMember = Membership.ValidateUser(User.Identity.Name, "Administrators");

    C
    bool isMember = Roles.GetRolesForUser("Administrators").Any();

    D
    bool isMember = User.IsInRole("Administrators");

    Note: Not available
    1. Report
  9. Question: You are creating an ASP.NET Web site. You create a HTTP module named CustomModule, and you register the module in the web.config file. The CustomModule class contains the following code. public class CustomModule : IHttpModule { string footerContent = "<div>Footer Content</div>"; public void Dispose() {} } You need to add code to CustomModule to append the footer content to each processed ASP.NET page. Which code segment should you use?

    A
    public CustomModule(HttpApplication app) { app.EndRequest += new EventHandler(app_EndRequest); void app_EndRequest(object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; app.Response.Write(footerContent); }

    B
    public void Init(HttpApplication app) { app.EndRequest += new EventHandler(app_EndRequest); void app_EndRequest(object sender, EventArgs e) { HttpApplication app = new HttpApplication(); app.Response.Write(footerContent); }

    C
    public customModule(); { HttpApplication app = new HttpApplication(); app.EndRequest += new EventHandler(app_EndRequest); } void app_EndRequest(object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; app.Response.Write(footerContent); }

    D
    public void Init(HttpApplication app) { app.EndRequest += new EventHandler(app_EndRequest); } void app_EndRequest(object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; app.Response.Write(footerContent); }

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd