News:

SQL Table To C# Entity Model ConverterEntity Model (Class Properties) to SQL Table ConverterIf you encounter any trouble visiting our site, please contact us.

Mcq Answers for Asp.net

01 namespace DevControls
02{
03public class Task : WebControl
04{
05 [DefaultValue("")]
06public string Title { ... }
08protected override void RenderContents(
HtmlTextWriter output)
09{
10output.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\" />");

Answer: Answer is a, c

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

  1. 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);
    }
    
  2. 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");
    }
    
  3. 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);
    }
    
  4. 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");
    }
    
Answer: Answer is b

<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.)

  1. this.hdr1.InnerHtml = "Text";
  2. (hdr1.Parent as HtmlGenericControl).InnerText = "Text";
  3. HtmlGenericControl h1 =this.FindControl("hdr1") as HtmlGenericControl;
    h1.InnerText = "Text";
    
  4. HtmlGenericControl h1 =Parent.FindControl("hdr1") as HtmlGenericControl;
    h1.InnerText = "Text";
    
Answer: Answer is a, c

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?

  1. 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");
    
  2. 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);
    
  3. 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);
    
  4. 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);
    
Answer: Answer is d

  1. bool isMember = Roles.GetUsersInRole("Administrators").Any();
    
  2. bool isMember = Membership.ValidateUser(User.Identity.Name, "Administrators");
    
  3. bool isMember = Roles.GetRolesForUser("Administrators").Any();
    
  4. bool isMember = User.IsInRole("Administrators");
    
Answer: Answer is d

public class CustomModule : IHttpModule
{
string footerContent = "
Footer Content
";
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?

  1. 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);
    }
    
  2. 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);
    }
    
  3. 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);
    }
    
  4. 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);
    }
    
Answer: Answer is d

  1. Add the following configuration to the web.config file.

    <system.web>
    <customErrors mode="On">
    <error statusCode="500" redirect="~/Error.aspx" />
    </customErrors>
    </system.web>
  2. Add the following configuration to the web.config file.

    <system.web>
    <customErrors redirectMode="ResponseRewrite"
    mode="On" defaultRedirect="~/Error.aspx" />
    </system.web>
    <system.web>
    <customErrors redirectMode="ResponseRewrite"
    mode="On" defaultRedirect="~/Error.aspx" />
    </system.web>
  3. Add the following code segment to the Global.asax file.

    void Application_Error(object sender, EventArgs e)
    {
    Response.Redirect("~/Error.aspx");
    }
  4. Add the following code segment to the Global.asax file.

    void Page_Error(object sender, EventArgs e)
    Server.Transfer("~/Error.aspx");
    }
    
Answer: Answer is b

  1. void Application_Start(object sender, EventArgs e)
    {
    SiteHelper.Configure();
    }
    
  2. void Application_Init(object sender, EventArgs e)
    {
    SiteHelper.Configure();
    }
    
  3. void Application_BeginRequest(object sender, EventArgs e) {
    SiteHelper.Configure();
    }
    
  4. Object lockObject = new Object();
    void Application_BeginRequest(object sender, EventArgs e)
     {
     lock(lockObject())
     {
     SiteHelper.Configure();
     }
    }
    
Answer: Answer is a

  1. In the context menu for the service reference in the ASP.NET project, select the Configure Service
    Reference command, and set the collection type to System.Collections.Generic.List.

  2. In the context menu for the service reference in the ASP.NET project, select the Update Service Reference command to retrieve the new service configuration.

  3. Change the service interface and implementation to return a List<Person>

  4. Edit the address property of the endpoint element in the web.config file to use the new service address.

Answer: Answer is a, d

  1. <configuration>
    <system.net>
    <mailSettings>
    <smtp configSource="smtp.config" allowOverride="true">
    <network host="127.0.0.1" port="25"/>
    </smtp>
    </mailSettings>
    </system.net>
    </configuration> 
  2. <configuration>
    <system.net>
    <mailSettings>
    <smtp configSource="smtp.config" />
    </mailSettings>
    </system.net>
    </configuration>
  3. <configuration xmlns:xdt="http://schemas.microsoft.com/XML- Document-Transform">
    <location path="smtp.config" xdt:Transform="Replace"
    xdt:Locator="Match(path)">
    <system.net />
    </location>
    </configuration>
  4. <configuration>
    <location path="smtp.config">
    <system.net>
    <mailSettings>
    <smtp Devilery Method="Network" >
    <Network Host = "127.0.0.1" Port="25"/>
    </smtp>
    </mailSettings>
    </system.net>
    </location>
    </configuration>
Answer: Answer is b

Advertisement

BCS Preparation now even more easy. ReadBD is the place where you can find all kind of resources to be successful in BCS,Bank,Islami Bank exam and interview.

Looking for job. Try JobLoader- First ever job search engine in Bangladesh. All open bd jobs now a single mouse click away.

;