Tuesday, November 4, 2008

at 1:35 AM Posted by senthil

1) In asp.net 2.0 what is the best way to handle sql connection state?

Answer Description:

As per the standard guideline connection object should be dispose in any case so that dangling connection object should not lie in memory. Connection object is handling SQL server connection which can not be disposing by .NET garbage collector.
To achieve this behavior we should always use try finally block which handling connection object and make sure to calling dispose method of connection object into finally block.

System.Data.SqlClient.SqlConnection connection =

new System.Data.SqlClient.SqlConnection();

try

{

connection.Open();

//do some work

}

finally

{

connection.Dispose();

}

There is a “using” statement in .net framework which is a shortcut of try finally block.

using ( System.Data.SqlClient.SqlConnection connection =

new System.Data.SqlClient.SqlConnection() )

{

connection.Open();

//do some work

//no need to call connection.Dispose()

}

2) In asp.net 2.0 I want use same header and footer for number of pages. What are the best ways to do minimum level of code and how I can use?

Answer Description:

ASP.NET 2.0 master pages allow developers to develop a uniform and consistent layout for the pages in your ASP.NET 2.0 application. Master page defines the layout (look and feel) and standard behavior that developer wants for all of the pages (or a group of pages) in asp.net 2.0 application. Developer can then create individual content pages that contain the content you want to display. When users request the content pages, master page and content page merge to produce output that combines the layout of the asp.net 2.0 master pages with the content from the content page.

3) Which class can be used to perform data type conversion between .NET data types and XML types?

  • 1. XmlType
  • 2. XmlCast
  • 3. XmlConvert (Correct)
  • 4. XmlSettings

4) Which class can be used to create an XML document from scratch?

  • 1. XmlConvert
  • 2. XmlDocument (Correct)
  • 3. XmlNew
  • 4. XmlSettings

5) To perform asynchronous data access, what must be added to the connection string?

  • 1. BeginExecute=true
  • 2. MultiThreaded=true
  • 3. MultipleActiveResultSets=true
  • 4. Asynchronous=true (Correct)

6) What event can you subscribe to if you want to display information from SQL Print statements?

  • 1. InfoMessage (Correct)
  • 2. MessageReceived
  • 3. PostedMessage
  • 4. NewInfo

7) Which of the following ways can you proactively clean up a database connection’s resources?

1. Execute the DbConnection object’s Cleanup method.

2. Execute the DbConnection object’s Close method.

3. Assign Nothing (C# null) to the variable that references the DbConnection object.

4. Create a using block for the DbConnection object.

1. Execute the DbConnection object’s Cleanup method.

2. Execute the DbConnection object’s Close method. (Correct)

3. Assign Nothing (C# null) to the variable that references the DbConnection object.

4. Create a using block for the DbConnection object. (Correct)

8) You are working with a DataSet and want to be able to display data, sorted different ways. How do you do so?

  • 1. Use the Sort method on the DataTable object.
  • 2. Use the DataSet object’s Sort method.
  • 3. Use a DataView object for each sort. (Correct)
  • 4. Create a DataTable for each sort, using the DataTable object’s Copy method, and then Sort the result.

9) Which of the following is a requirement when merging modified data into a DataSet?

  • 1. A primary key must be defined on the DataTable objects. (Correct)
  • 2. The DataSet schemas must match in order to merge.
  • 3. The destination DataSet must be empty prior to merging.
  • 4. A DataSet must be merged into the same DataSet that created it.

10) While developing ASP.NET 2.0 web application you have a DataSet containing a Customer DataTable and an Order DataTable. You want to easily navigate from an Order DataRow to the Customer who placed the order. What object will allow you to easily navigate from the Order to the Customer?

  • 1. The DataColumn object
  • 2. The DataTable object
  • 3. The DataRow object
  • 4. The DataRelation object (Correct)

11) While developing ASP.NET 2.0 web application you want to display a list of parts in a master/detail scenario where the user can select a part number using a list that takes a minimum amount of space on the Web page. When the part is selected, a DetailsView control displays all the information about the part and allows the user to edit the part. Which Web control is the best choice to display the part number list for this scenario?

  • 1. The DropDownList control (Correct)
  • 2. The RadioButtonList control
  • 3. The FormView control
  • 4. The TextBox control

12) In your ASP.NET web application you want to display a list of clients on a Web page. The client list displays 10 clients at a time, and you require the ability to edit the clients. Which Web control is the best choice for this scenario?

  • 1. The DetailsView control
  • 2. The Table control
  • 3. The GridView control (Correct)
  • 4. The FormView control

13) In your ASP.NET 2.0 web application you want to display an image that is selected from a collection of images. What approach will you use to implementing this?

  • 1. Use the ImageMap control and randomly select a HotSpot to show or hide.
  • 2. Use the Image control to hold the image and a Calendar control to randomly select a date for each image to be displayed.
  • 3. Use the AdServer control and create an XML file with configuration of the control. (Correct)
  • 4. Use an ImageButton control to predict randomness of the image to be loaded based on the clicks of the control.

14) You are writing ASP.NET 2.0 Web site that collects lots of data from users, and the data collection forms spreads over multiple ASP.NET Web pages. When the user reaches the last page, you need to gather all of data, validate the data, and save the data to the SQL Server database. You have noticed that it can be rather difficult to gather the data that is spread over multiple pages and you want to simplify this application. What is the easiest control to implement that can be used to collect the data on a single Web page?

  • 1. The View control
  • 2. The TextBox control
  • 3. The Wizard control (Correct)
  • 4. The DataCollection control

15) For your ASP.NET web application your graphics designer created elaborate images that show the product lines of your company. Some of graphics of the product line are rectangular, circular, and others are having complex shapes. You need to use these images as a menu on your Web site. What is the best way of incorporating these images into your Web site?

  • 1. Use ImageButton and use the x- and y-coordinates that are returned when the user clicks to figure out what product line the user clicked.
  • 2. Use the Table, TableRow, and TableCell controls, break the image into pieces that are displayed in the cells, and use the TableCell control’s Click event to identify the product line that was clicked.
  • 3. Use the MultiView control and break up the image into pieces that can be displayed in each View control for each product line. Use the Click event of the View to identify the product line that was clicked.
  • 4. Use an ImageMap control and define hot spot areas for each of the product lines. Use the PostBackValue to identify the product line that was clicked. (Correct)

16) Which of the following represents the best use of the Table, TableRow, and Table-Cell controls?

  • 1. To create and populate a Table in Design view
  • 2. To create a customized control that needs to display data in a tabular fashion (Correct)
  • 3. To create and populate a Table with images
  • 4. To display a tabular result set

17) In the Design view in Visual Studio 2005 of an ASP.NET web page, what is the easiest way to create an event handler for the default event of a ASP.NET server control?

  • 1. Open the code-behind page and write the code.
  • 2. Right-click the control and select Create Handler.
  • 3. Drag an event handler from the ToolBox to the desired control.
  • 4. Double-click the control. (Correct)

18) While creating an ASP.NET web application with the help of Visual Studio 2005 you are creates a Web page that has several related buttons, such as fast-forward, reverse, play, stop, and pause. There should be one event handler that handles the processes of PostBack from these Button server controls. Other than the normal Submit button, what type of button can you create?

  • 1. OneToMany
  • 2. Command (Correct)
  • 3. Reset
  • 4. ManyToOne

19) While creating your ASP.NET web based application you want to create multiple RadioButton server controls which should be mutually exclusive, what property of RadioButton server controls you must set?

  • 1. Exclusive
  • 2. MutuallyExclusive
  • 3. Grouped
  • 4. GroupName (Correct)

20) While writing code in Visual Studio 2005 you creates a new instance of a ASP.NET TextBox server control, what do you need to do to get the TextBox to display on the Web page?

  • 1. Call the ShowControl method on the TextBox.
  • 2. Set the VisibleControl to true on the TextBox.
  • 3. Add the TextBox instance to the form1.Controls collection. (Correct)
  • 4. Execute the AddControl method on the Web page.

21) While testing your ASP.NET web application you noticed that while clicking on CheckBox of one of the web page it does not cause a PostBack; you required that the CheckBox should make PostBack so Web page can be update on the server-side code. How can you make the CheckBox to cause a PostBack?

  • 1. Set the AutoPostBack property to true. (Correct)
  • 2. Add JavaScript code to call the ForcePostBack method.
  • 3. Set the PostBackAll property of the Web page to true.
  • 4. Add server-side code to listen for the click event from the client.

22) While creating web site you need to add an HTML Web server control to the Web page, you need to drag an HTML element from the ToolBox of Visual Studio 2005 to the Web page and then which of the following tasks you will perform?

  • 1. Right-click the HTML element and click Run=Server.
  • 2. Double-click the HTML element to convert it to an HTML server control.
  • 3. Right-click the HTML element and click Run As Server Control. (Correct)
  • 4. Click the HTML element and set ServerControl to true in the Properties window.

23) You are interested in examining the data that is posted to the Web server. What trace result section can you use to see this information?

  • 1. Control Tree
  • 2. Headers Collection
  • 3. Form Collection (Correct)
  • 4. Server Variables

24) How many classes can a single .NET DLL contain

One
(Correct)

25) How will you identify which event in the ASP.NET Web page life cycle takes the longest time to execute?

  • 1. Turn on ASP.NET trace and run the Web application. (Correct)
  • 2. Add a few code to each of the page life-cycle events that will print the current time.
  • 3. In the Web.config file, add the monitorTimings attribute and set it to True.
  • 4. In the Web site properties, turn on the performance monitor and run the Web application. After that, open performance monitor to see the timings.

26) For making a configuration setting change that will affect only the current Web application. Is there any tool that has a user-friendly Graphical User Interface (GUI)?

  • 1. The Microsoft Management Utility
  • 2. Microsoft Word
  • 3. Visual Studio, using the Tools > Options path
  • 4. Web Site Administration Too (Correct)

27) If you want to make a configuration setting change that will affect only the current Web application. Which file will you change?

  • 1. Web.config that is in the same folder as the Machine.config file (Correct)
  • 2. Web.config in the root of the Web application
  • 3. Machine.config
  • 4. Global.asax

28) If you want to make a configuration setting change in your server that will affect to all Web and Windows applications on the current machine. Where you will make the changes?

  • 1. Global.asax
  • 2. Web.config
  • 3. Machine.config (Correct)
  • 4. Global.asax

29) Amit created a new Web site using Visual Studio 2005 in programming language C#. Later, Amit received an existing Web page from his boss, which consisted of the Contact.aspx file with the Contact.aspx.vb code-behind page. What must Amit do to use these files?

  • 1. Amit can simply add the files Contact.aspx, Contact.aspx.vb into the existing Web site, because ASP.NET 2.0 supports Web sites that have Web pages that were programmed with different languages. (Correct)
  • 2. The Contact.aspx file will work, but Amit must rewrite the code-behind page using C#.
  • 3. Both files Contact.aspx and Contact.aspx.vb must be rewritten in C#.
  • 4. Amit must create a new Web site that contains these files Contact.aspx and Contact.aspx.vb. Set a Web reference to the new site.

30) For separating server-side code from client-side code on a ASP.NET page, what programming model should you use?

  • 1. Separation model
  • 2. Code-Behind model (Correct)
  • 3. In-Line model
  • 4. ClientServer model

31) If you want to create a new Web site with the help of Visual Studio 2005 on a Web server that is hosted by your ISP (Internet Services provider) and the Web server has Front Page Server Extensions installed, what type of Web site type would you create in Visual Studio 2005?

  • 1. Local HTTP
  • 2. File
  • 3. FTP
  • 4. Remote HTTP (Correct)

32) While creating a Web site with the help of Visual Studio 2005 on a remote computer that does not have Front Page Server Extensions installed, which Web site type will you create in Visual Studio 2005?

  • 1. Remote HTTP
  • 2. File
  • 3. FTP (Correct)
  • 4. Local HTTP

33) What is the name of the property of ASP.NET page that you can query to determine that a ASP.NET page is being requested not data being submitted to web server?

  • 1. FirstGet
  • 2. Initialized
  • 3. IncludesData
  • 4. IsPostBack (Correct)

34) You create a Web application to process XML documents. The Web application receives XML document files from several sources, reads them, and stores them in a Microsoft SQL Server database. The Web application parses all incoming data files to ensure that they conform to an XML schema. You need to find all validation errors in the XML document. What should you do?

  • 1. Load the XML data by using an instance of the XmlDocument class and specify a location for the application schema.
  • 2. Configure the ValidationEventHandler in the XmlReaderSettings of the XmlReader object. (Correct)
  • 3. Read the XML file into a DataSet object and set the EnforceConstraints property to True.
  • 4. Read the XML file into a DataSet object. Handle the DataSet.MergeFailed event to parse the data that does not conform to the XML schema.

35) In your ASP.NET Web application you use the following connection string to connect to the database. conn.ConnectionString = “Server=(local);Initial Catalog=NorthWind; Integrated Security=SSPI;”; You create logins in Microsoft SQL Server for each user of the Web application. When you run the Web application, you receive the following error message. "Login failed for user 'MYCOMPUTERNAME\ASPNET'." You need to resolve this. Which actions should you perform?

  • 1. In IIS, deny anonymous access. (Correct)
  • 2. In the Web.config file, enable impersonation (Correct)
  • 3. In IIS, allow anonymous access.
  • 4. In the Web.config file, disable impersonation.

36) You are using the ASP.NET membership APIs to manage user accounts for your ASP.NET Web site. The Web.config file of your web site contains the definition for the membership provider. You modified the Web.config file to enable password recovery, you create a PasswordChange.aspx.you need to enable users to reset their passwords online. The new passwords must be sent to users by email. In addition, users must be required to answer their secret questions before changing their passwords.Which logic you use?

  • 1. Add a PasswordRecovery element to the PasswordChange.aspx file and configure it. (Correct)
  • 2. Modify the Page_Load to set the Membership.EnablePasswordReset to True in the PasswordChange.aspx.
  • 3. Add a ChangePassword element to the PasswordChange.aspx file and configure it.
  • 4. Modify the Login.aspx form to include a Required Field validator on the secret question answer text box. Then redirect users to the PasswordChange.aspx file.

37) You company gives you a task to secure existing ASP.NET Web site by redirecting all users to the logon page, Login.aspx. After logging on, users must be redirect to the page that they originally requested.

Which should you use?

  • 1. In the Web.config file: On each page in the Web site: void Page_Load(Object sender, EventArgs E){ FormsAuthentication.Initialize();
  • 2. On each page in the Web site: void Page_Load(Object sender, EventArgs E){ FormsAuthentication.RedirectToLoginPage(“login.aspx”);
  • 3. On each page in the Web site: void Page_Load(Object sender, EventArgs E){ Response.Redirect(“login.aspx”);//Rest of the Page_Load code goes here}
  • 4. In the Web.config file: (Correct)

38) In ASP.NET web application you are creating a Web Form. This Web Form allows users to log on to a Web site which use a Login control named Login1. Membership data for the application is stored in a SQL Express database and .mdf file is in the App_Data directory. In ASP.NET web application you have to configure your application so that the membership data is stored in a local Microsoft SQL Server database. You have following setting in the Web.config file. Which else should you perform?

  • 1. Run Aspnet_regsql.exe to create the Microsoft SQL Server database.
  • 2. Set Login1's MembershipProvider property to MyOrgSqlProviderConnection. (Correct)
  • 3. Add the following code in the Web.config file.
  • 4. Add the following code in the Web.config file. (Correct)

39) You are having responsibility to develop a Web application that writes a file on a web server. You restrict access to the file to specific Windows users. Your Web application runs under MYORG\ASPNET. IIS settings deny anonymous access to the application. Web.Config is having following authentication mode.Your asp.net web application must meet the following requirements:1. If user does not access the file It must run as MYORG\ASPNET.2. Impersonation of the user when it writes the fileWhich actions you will perform?

  • 1. Use the following XML in the Web.config file. (Correct)
  • 2. Use the following XML in the Web.config file.
  • 3. Use the following code segment to access the file. WindowsIdentity wini = WindowsIdetity.GetCurrent();WindowsImpersonationContext winic = WindowsIdentity.Impersonate(wini.Token);
  • 4. Use the following code to access the file. WindowsPrincipal winp =(WindowsPrincipal)HttpContext,Current.User;WindowsIdentity wini = (WindowsIdentity)wp.Idetity;WindowsImpersonationContext winic = wini.Impersonate(); (Correct)

40) Your Web site has many predefined roles and associated users for security purposes. Which tool you use to manage these roles and user accounts?

  • 1. The Microsoft .NET Framework Configuration tool.
  • 2. The Code Access Security Policy tool.
  • 3. The Web Site Administration Tool. (Correct)
  • 4. The ASP.NET IIS Registration tool

41) Web site for organization members changing the behavior according to the role of the users. The Web site uses the ASP.NET Membership control for creation of user accounts. How you will find out whether a user is a member of a particular role or not?

  • 1. Pass the user names and passwords to Membership.ValidateUser
  • 2. Pass the role names to Roles.RoleExists.
  • 3. Pass the user names to Membership.GetUser.
  • 4. Pass the role names to User.IsInRole. (Correct)

42) For intranet based Web application reads comma-delimited text files. The files reside in a subdirectory root directory. Users are not allowed to navigate directly to these files in a Web browser unless they are members of the Accounting role. You need to write an ASP.NET HTTP handler that will use the FileAuthorizationModule class. What type of authentication you will implement.

  • 1. Anonymous
  • 2. Certificate
  • 3. Forms
  • 4. Microsoft Windows Integrated Security (Correct)

43) Where does the ASP.NET Web page belong in the .NET Framework class hierarchy?

  • 1. System.Web.UI.Control
  • 2. System.Web.UI.Page (Correct)
  • 3. System.Web.UI.WebPage
  • 4. System.Web.UI.Form

44) What is the sequence of event firing during page load of asp.net page life cycle?

  • 1. Init(), Load(), PreRender(), Unload() (Correct)
  • 2. Load(), Init(), PreRender(), Unload()
  • 3. Init(), Load(), Unload(), PreRender()
  • 4. Init(), PreRender(),Load(), Unload()

45) For your ASP.NET web application your graphics designer created elaborate images that show the product lines of your company. Some of graphics of the product line are rectangular, circular, and others are having complex shapes. You need to use these images as a menu on your Web site. What is the best way of incorporating these images into your Web site?

  • 1. Use ImageButton and use the x- and y-coordinates that are returned when the user clicks to figure out what product line the user clicked.
  • 2. Use the Table, TableRow, and TableCell controls, break the image into pieces that are displayed in the cells, and use the TableCell control’s Click event to identify the product line that was clicked.
  • 3. Use the MultiView control and break up the image into pieces that can be displayed in each View control for each product line. Use the Click event of the View to identify the product line that was clicked.
  • 4. Use an ImageMap control and define hot spot areas for each of the product lines. Use the PostBackValue to identify the product line that was clicked. (Correct)

0 comments: