单项选择题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 namedAdministrators. 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")


您可能感兴趣的试卷

你可能感兴趣的试题

1.多项选择题You create an ASP.NET page that contains the following tag.  Page Name  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?()

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";

2.单项选择题

You are implementing an ASP.NET page that includes the following drop-down list.
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
B.Add the following OnPreRender event handler to the asp:DropDownList
C.Add the following event handler to the page code-behind.
D.Add the following event handler to the page code-behind.

3.多项选择题

You create a custom server control named Task that contains the following code segment.
You need to ensure that adding a Task control from the Toolbox creates markup in the following format. 
  
Which two actions should you perform?()

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\" />");

4.多项选择题You use the following declaration to add a Web user control named TestUserControl.ascx to an ASP.NET page named TestPage.aspx.    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?()

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"/>

5.多项选择题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. 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?()

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

6.单项选择题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); }

8.单项选择题

You are implementing an ASP.NET Web site. 
The site allows users to explicitly choose the display language for the site's Web pages. You create a Web page that contains a DropDownList named ddlLanguage, as shown in the following code segment.

The site contains localized resources for all page content that must be translated into the language that is selected by the user. You need to add code to ensure that the page displays content in the selected language if the user selects a language in the drop-down list. Which code segment should you use?()

A.protected void SelectedLanguageChanged(object sender, EventArgs e) {Page.UICulture = ddlLanguage.SelectedValue;}
B.protected override void InitializeCulture() {Page.UICulture = Request.Form["ddlLanguage"];}
C.protected void Page_Load(object sender, EventArgs e) {Page.Culture = Request.Form["ddlLanguage"];}
D.protected override void InitializeCulture() {Page.Culture = ddlLanguage.SelectedValue;}

9.单项选择题

You are creating an ASP.NET Web site. 
The site has a master page named Custom.master. 
The code-behind file for Custom.master contains the following code segment. 
You create a new ASP.NET page and specify Custom.master as its master page. You add a Label control named lblRegion to the new page. 
You need to display the value of the master page’s Region property in lblRegion. What should you do? ()

A.Add the following code segment to the Page_Load method of the page code-behind file. CustomMaster custom = this.Parent as CustomMaster; lblRegion.Text = custom.Region;
B.Add the following code segment to the Page_Load method of the page code-behind file. CustomMaster custom = this.Master as CustomMaster; lblRegion.Text = custom.Region;
C.Add the following code segment to the Page_Load method of the Custom.Master.cs code-behind file. Label lblRegion = Page.FindControl("lblRegion") as Label; lblRegion.Text = this.Region;
D.Add the following code segment to the Page_Load method of the Custom.Master.cs code-behind file. Label lblRegion = Master.FindControl("lblRegion") as Label; lblRegion.Text = this.Region;

10.单项选择题You are implementing an ASP.NET application that includes a page named TestPage.aspx. TestPage.aspx uses a master page named TestMaster.master. You add the following code to the TestPage.aspx code-behind file to read a TestMaster.master public property named CityName. protected void Page_Load(object sender, EventArgs e) { string s = Master.CityName; }  You need to ensure that TestPage.aspx can access the CityName property. What should you do?()

A.Add the following directive to TestPage.aspx. <%@ MasterType VirtualPath="~/TestMaster.master" %><%@ mastertype="" virtualpath="~/TestMaster.master">
B.Add the following directive to TestPage.aspx. <%@ PreviousPageType VirtualPath="~/TestMaster.master" %><%@ previouspagetype="" virtualpath="~/TestMaster.master">
C.Set the Strict attribute in the @ Master directive of the TestMaster.master page to true.
D.Set the Explicit attribute in the @ Master directive of the TestMaster.master page to true.

最新试题

Which class is used to specify a set of features to support on the XrnlReader object created by the Create method?()

题型:单项选择题

You have a login.ascx control and to display it in a view which method u would use()

题型:单项选择题

You are perfoming security testing on an existing asp.net web page.You notice that you are able to issue unauthorised postback requests to the page. You need to prevent unauthorised post back requests. which page directive you use?()

题型:单项选择题

Which class defines the contract that ASP.NET implements to provide membership services using custom membership providers?()

题型:单项选择题

You work as an ASP.NET Web Application Developer for SomeCompany. The company uses Visual Studio .NET 2010 as its application development platform. You have recently finished the development of an ASP.NET Web application using .NET Framework 4.0. Now, you are deploying the ASP.NET Web application to a remote server. You are required to select a deployment method that will make sure that all Internet Information Services (IIS) settings, in addition to the Web content, are deployed to the remote server. Which of the following deployment methods will you select to accomplish this?()

题型:单项选择题

You are developing an ASP.NET Web page that uses jQuery validation. The user should enter a valid email address in a text box that has ID txtEmail. The page must display "E-Mail address required" when the user does not enter an address and "Invalid e-mailaddress" when the user enters an address that is not formatted properly. You need to ensure that the appropriate error message is displayed when the text box does not contain a valid e-mail address.  Which two code segments should you add?()

题型:多项选择题

ou are developing an ASP.NET MVC 2 application. You create a view that will be returned by action methods in multiple controllers. You need to place the view in the appropriate folder. To which subfolder within the Views folder should you add the view?()

题型:单项选择题

Which method of the ChildActionExtensions class calls a child action method and renders the result inline in the parent view?()

题型:单项选择题

You have migrated a web application from .net 3.5 to 4.0. the application hat to render same as in .net 3.5.()

题型:单项选择题

You work as an ASP.NET Web Application Developer for SomeCompany.  The company uses Visual Studio .NET 2010 as its application development platform. You create an ASP.NET Web application using .NET Framework 4.0. You create a Web page in the application. The Web page will get large sets of data from a data source.  You add a DataPager control to the page. You are required to display navigation controls that enable you to create a custom paging Ul for the DataPager control. What will you do?()

题型:单项选择题