Monday, January 24, 2011

Brain dump sheet for 70-564 certification

Here are my notes, laid out as a Q&A, for the next exam I am preparing, the last one to become Microsoft Certified Professional Developer (MCPD): ASP.NET Developer 3.5 ...wow ;-)
I have prepared this article using OneNote within SkyDrive. This is by the way an excellent tool to take notes, share them and access them from everywhere and for free.

Q1: What are the different Page directives?
The author of this article gives this definition for Pages Directives:
Asp.Net Page directives are something that is a part of every asp.net pages. Page directives are instructions, inserted at the top of an ASP.NET page, to control the behavior of the asp.net pages. So it is type of mixed settings related to how a page should render and processed.
The reference article on MSDN gives all the details regarding Page Directives.

Q2: What are the different application folders?
Based on this MSDN article, ASP.NET recognizes certain folder names that you can use for specific types of content. The table below lists the reserved folder names and the type of files that the folders typically contain. Following folders can be used:
·         App_Browsers: Contains browser definitions (.browser files)
·         App_Code: Contains source code for utility classes and business objects that you want to compile as part of your application.
·         App_Data: Contains application data files including MDF files, XML files, as well as other data store files.
·         App_GlobalResources: Contains resources (.resx and .resources files) that are compiled into assemblies with global scope
·         App_LocalResources: Contains resources that are associated with a specific page, user control, or master page in an application
·         App_Themes: Contains a collection of files (.skin and .css files...) that define the appearance of ASP.NET Web pages and controls
·         App_WebReferences: Contains files that defines a Web reference for use in an application.(.wsdl , .xsd,.disco and .discomap files)
·         Bin: Contains compiled assemblies (.dll files)

Q3: What is a JSON web service in asp.net?
JSON for JavaScript Object Notation specifies how the Web method return-type is serialized. For your information, the other one is XML.
Using this article and the code given by the author, i made a web service test and play with the result. Here is the result I get while invoking the web service:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">
[["CarNumber1","CarColor1","CarMotor1"],["CarNumber2","CarColor2","CarMotor2"]]
</string>

I am not really sure of the added value of such format… will see...

Q4: What is the difference between a web site and a web application?
Here is what I found when googling this question:
A web site is just a group of all files in a folder and sub folders. There is no project file. All files under the specific folder - including your word documents, text files, images etc. are part of the web site.
You have to deploy all files including source files (unless you pre compile them) to the server. Files are compiled dynamically during run time.
As a conclusion, the author writes:
·         A web site is good for you if you just want to create web sites and share with others. It is ideal for new projects.
·         However, "web application project" is better if you are planning to migrate your Visual Studio 2003 or 2002 web sites into Visual Studio 2005. Otherwise you may end up spending lot of time to exclude unwanted files from your web site folder.
The full article is visible on dotnetspider.com

Q5: What are Session state modes and how to use them?
Session state modes define the way how session state information is stored. Here are the definitions taken from the MSDN article and the main information to remember:
·          InProc mode, which stores session state in memory on the Web server. This is the default.
·          StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
·          SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
·          Custom mode, which enables you to specify a custom storage provider.
·          Off mode, which disables session state.

Q6: What are "Custom Profile Provider" and "Custom Membership Provider"?
For this subject, i also googled and find the following sites that contain definitions and samples:
·         For Profile provider (DavidHayden.com)
·         For Membership Provider (MSDN)

Bonus "question", list of control we should know for this exam, with a link to an MSDN article
·          FormView:
The FormView control is used to display a single record from a data source in a table. When using the FormView control, you specify templates to display and edit bound values. The templates contain formatting, controls, and binding expressions to create the form. The FormView control is often used in combination with a GridView control for master/detail scenarios. This section contains the following topics about the FormView control
·          ListView:
Displays the values of a data source by using user-defined templates. The ListView control enables users to select, sort, delete, edit, and insert records.
·          DataList:
A data bound list control that displays items using templates.
·          Repeater:
A data-bound list control that allows custom layout by repeating a specified template for each item displayed in the list.
·          DetailsView:
Displays the values of a single record from a data source in a table, where each data row represents a field of the record. The DetailsView control allows you to edit, delete, and insert records.

Friday, January 7, 2011

Some tips on ASP.NET, 70-562 certification cheat sheet

I wanted with this post to give a list of tips around asp.net (as part of my next certification 70-562 TS Microsoft .NET Framework 3.5, ASP.NET Application Development)
The first element ASP.net developer should know is the ASP.net page life cycle. Knowing this area will allow you to correctly initialize controls. Here is a great article on MSDN on the life cycle, which details the following sections:
·         Life-cycle Events
·         Login Control Events

The second point is related to page redirection and page transfer. What is the difference between:
·         Response.Redirect("url");
·         Server.Transfer("url");
·         HttpContext.Current.RewritePath("url");

This article gives a very good comparison between Response.Redirect and Server.Transfer.
As a summary, the author gives the following points:
·         Response.Redirect is more user-friendly, as the site visitor can bookmark the page that they are redirected to.
·         Transferred pages appear to the client as a different url than they really are. This means that things like relative links / image paths may not work if you transfer to a page from a different directory.
·         Server.Transfer has an optional parameter to pass the form data to the new page.
The last option, HttpContext.Current.RewritePath, is cleverly detailed in this article with a very simple to understand example.
The detail of the HttpContext.RewritePath Method is explained in this MSDN article.

The third tip of this post is the difference between #EVAL and #BIND.
In few words, #EVAL is one-way(read-only) and #BIND is a two-way (updatable) binding.
Data-binding expressions are contained within <%# and %> delimiters and use the Eval and Bind functions. The Eval function is used to define one-way (read-only) binding. The Bind function is used for two-way (updatable) binding. In addition to calling Eval and Bind methods to perform data binding in a data-binding expression, you can call any publicly scoped code within the <%# and %> delimiters to execute that code and return a value during page processing.
Very stupid stuff to remember, single-quotes should be used and not double-quotes
<asp:TextBox Runat="server" ID="txtProductName" Text='<%# Bind("ProductName") %>' />

Forth tip, let's discuss about AJAX and the difference between $get and $find
$get is an alias for getElementById. In addition, this function has additional code for those browsers that have not implemented getElementById. (Labels, textboxes are example of elements)
$find is a shortcut for Sys.Application.findComponent. (Widgets like calendars are examples of components)
This excellent article gives a quick summary of the differences:
·         Both, $get and $find, appear return a reference to a DOM object created using mark-up or at runtime
·         Both, $get and $find, appear to return a component reference
·         While both methods work on elements and components, it’s recommended to use $get for elements and $find for components.