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 MVC

public class ProductController : Controller
{
static List products = new List();
public ActionResult Index()
{
return View();
}
}

In the Views folder of your application, you add a view page named Index.aspx that includes the following @Page directive.

<%@ Page Inherits="System.Web.Mvc.ViewPage" %>

You test the application with a browser. You receive the following error message when the Index method is invoked: "The view 'Index' or its master was not found." You need to resolve the error so that the new view is displayed when the Index method is invoked. What should you do?

  1. Change the name of the Index.aspx file to Product.aspx

  2. Create a folder named Product inside the Views folder. Move Index.aspx to the Product folder

  3. Replace the @ Page directive in Index.aspx with the following value

    <%@ Page Inherits="System.Web.Mvc.ViewPage" %>
    
  4. Modify the Index method by changing its signature to the following:

    public ActionResult Index(Product p)
    
Answer: Answer is b

public class DepartmentController : Controller
{
static List departments =
new List();
public ActionResult Index()
{
return View(departments);
}
public ActionResult Details(int id)
{
return View(departments.Find(x => x.ID==id));
}
public ActionResult ListEmployees(Department d)
{
List employees = GetEmployees(d);
return View(employees);
}
}

You create a strongly typed view that displays details for a Department instance. You want the view to also include a listing of department employees. You need to write a code segment that will call the ListEmployees action method and output the results in place. Which code segment should you use?

  1. <%= Html.Action("ListEmployees", Model) %>
    
  2. <%= Html.ActionLink("ListEmployees", "Department", "DepartmentController") %>
    
  3. <% Html.RenderPartial("ListEmployees", Model); %>
    
  4. <%= Html.DisplayForModel("ListEmployees") %>
    
Answer: Answer is a

  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 %>" />
Answer: Answer is d

  1. btnAddToCart_Click

  2. Page_Load

  3. Page_PreRender

  4. Page_PreInit

Answer: Answer is c

 <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();
    }
    }
    
Answer: Answer is b

  1. Init

  2. Load

  3. PreInit

  4. PreLoad

Answer: Answer is b

  1. Modify the hosting page's caching directive as follows

    <%@ OutputCache Duration="10" VaryByParam="None" %>
    
  2. Add the following meta tag to the Head section of the hosting page.

    <meta http-equiv="refresh" content="10">
  3. Add the following caching directive to the hosted control.

    <%@ OutputCache Duration="10" VaryByParam="None" %>
  4. Add the following caching directive to the hosted control.

    <%@ OutputCache Duration="10" VaryByControl="None" %>
Answer: Answer is a, c

  1. Require developers to set EnableViewStateMac to true.

  2. Store state in ControlState instead of ViewState.

  3. Serialize the state into an Application state entry called "MyControl"

  4. Require developers to change the session state mode to SQL Server.

Answer: Answer is b

  1. Set viewStateEncryptionMode to Auto in web.config on both servers

  2. Set the machineKey in machine.config to the same value on both servers.

  3. Change the session state mode to SQL Server on both servers and ensure both servers use the same connection string

  4. Override the SavePageStateToPersistenceMedium and LoadPageStateFromPersistenceMedium methods in the page base class to serialize the view state to a local web server file.

Answer: Answer is b

  1. Configure the input control to run on the server. On the submit button, add a server-side OnClick handler that calls CheckCreditCard and rejects the form submission if the input is invalid.

  2. On the input control, add an onChange handler that calls CheckCreditCard and cancels the form submission when the input is invalid

  3. Configure the input control and the submit button to run on the server. Add a submit_OnClick handler that calls CheckCreditCard and rejects the form submission if the input is invalid.

  4. On the form, add an onSubmit handler that calls CheckCreditCard and cancels the form submission if the input is invalid

Answer: Answer is d

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.

;