Wednesday, October 20, 2004
Article published in MSDN
Saturday, October 09, 2004
Time and again there have been major changes happening in web development and this time around, it is this version release from Microsoft that is really going to make a difference. From Asp.Net version 1.x to Asp.Net 2.0, many new features have been introduced. The web development is going to become easier and interesting with ASP.NET 2.0. This article being a first insight into this new version, will just lay a hand on the nuts and bolts and will not be dealing with any of the concepts in detail. The following are some of the key features of Asp.Net 2.0:
Ã Increase developer productivity: Development with ASP.NET 2.0 has reduced the number of lines of code required by 70%. The declarative programming model freed developers from having to write reams of code. More than 45 new server controls in Whidbey that enable powerful declarative support for data access, login security, wizard navigation, image generation, menus, treeviews, portals, and more. This reducing the amount of code required providing better solutions for common Web site scenarios (such as portals and personalized sites).
Ã Templates: ASP.NET 2.0 has the concept of master page, which provide a template for a consistent look and feel in the web page. A master page is an ASP.NET page that provides a template for other pages, giving shared page-level layout and functionality. The master page defines placeholders for the content, which can be overridden by child pages. This is more or less like a MDI concept in VB.
Ã Cross Page posting: In ASP.NET 1.x, Web Forms automatically postback to the same page. That is, when a user submits a form, the form data is always submitted back to the same page and the action property cannot be set and which when set might lead to "viewstate corrupted" error. In ASP.NET 2.0, if the developer wants to post data to a different form, it is now possible. The web form controls have a new property that lets the developer decide where the form data should be sent on a submit action.
Ã Securing your site: in Asp.Net 2.0, the login functionality includes various set of controls like : i) Login control, providing complete functionality for logging into a site, ii) LoginStatus control, which indicates the login status and can be configured to provide automatic links to login and logout pages, iii) LoginName control to display the current (or anonymous) name, iv) LoginView control, providing templated views depending on the login status, v) PasswordRecovery control, encompassing the "forgot my password" functionality
For example, to add login features to your page all we need to do is add the following code:
<asp:Login runat="server" />
Ã Styles: In ASP.NET 2.0 the concept that deals with the look and feel of a website is that of themes. This is something more or less equivalent to CSS in Asp.Net 1.x, but with a quite different approach. Some sites provide a selection of stylesheets or alternatively change the stylesheets on the server. This allows not only color schemes to be selected but also complete style choices, such as fonts, style of borders, and so on. In ASP.NET 2.0, this is implemented with 2 concepts named skins and themes. A skin is a set of properties and templates that can be applied to controls. A theme is a set of skins and any other associated files (such as images or stylesheets). Theming, or skinning, has become very popular, allowing users to create a customized look for applications.
Ã Provide easier and more sophisticated management features. Administration of ASP.NET applications under version 1.x required manual editing of the XML configuration file, which is not a great solution for administrators. Version 2.0 brings a graphical user interface Âbased administration tool that is integrated with the Internet Information Services (IIS) administration tool.
CODE COMPILATION MODEL
Now, let's now turn our attention to Code Compilation Model to know how things have changed in ASP.NET 2.0. First, the division of responsibility between base and derived classes goes away. Second, you no longer have to separately compile your user-defined code into an assembly that gets copied into the application's \bin directory. All code, both generated and user-defined is now compiled by the ASP.NET runtime into a single class.
There are two things to notice in an .aspx file. First, there is a new compileWith attribute in the @Page declaration. This tells the ASP.NET runtime the name of the code separation file that contains user-defined code. Second, the ASP.NET 1.x inherits attribute is no longer present. Recall that this attribute told the ASP.NET 1.x runtime what class to derive the ASP.NET page from.
Notice that codebehind file only contains the event handler for controlÂs event. The reason this code is so much simpler is due to a language feature called partial classes that is new to both C# and VB.NET. This feature lets a class definition span multiple source files, which is how VS.NET and ASP.NET can hide all of the standard initialization code from you. To understand how partial classes work, we need to take a closer look at the code that is generated by the ASP.NET runtime.
First, we need to run the application and force the ASP.NET runtime to dynamically compile your page. When we run our application using VS.NET IDE, actually we will notice two new things. First, there isn't a build step; it immediately start running the Web application. Second thing is that the ASP.NET code no longer runs in IIS during development instead, it runs in a new managed Web server called Visual Web Developer Web Server. This new design means that we don't need to install or configure IIS on a developer's computer. It also means that we can develop ASP.NET code using a restricted user account without having to reconfigure ASP.NET first.
After we run our application for the first time, we need to find where ASP.NET places the generated files. As it turns out, they're in a different location now. Because the Visual Web Developer Web Server runs using our credentials, we will find the files in Local Settings\Temp\Temporary ASP.NET Files\[virtual root]\[x]\[y]. When we look in this directory, actually we should find two .cs files.
There is a new feature in ASP.NET 2.0 that lets you put all related code, i.e. the code that isn't part of an ASP.NET page, in a subdirectory called Code. This can be other source code files, .wsdl files, or .xsd files. ASP.NET will invoke the appropriate command-line tools to compile these source code files at run-time.
Monday, October 04, 2004
Difference between Value Type and Reference Types
When your code defines a variable of a reference type, the variable is either a reference to an object or it is a null reference. In contrast, a variable of a value type is the actual data, and no reference is involved. Many programming languages provide built-in data types such as integers and floating-point numbers. These are copied when they are passed in to arguments i.e. they are passed "By Value". In .NET terms, these are called Value Types".
The RunTime supports two kinds of Value Types:
1 Built-in value types
The .NET Framework defines built-in value types such as System.Int32 and System.Boolean which correspond and are identical to primitive data types used in programming languages.
2 User-defined value types
The language you are using will provide functionality to define your own Value Types. These user defined Types derive from System.ValueType. If you want to define a Type representing a value that is a complex number (two floating-point numbers), you might choose to define it as a value type. Because you can pass the Value Type efficiently "By Value".
If the Type you are defining could be more efficiently passed "By Reference", you should define it as a class instead. Variables of Reference Types are referred to as objects. These store references to the actual data.
The following are the Reference Types:
This following are the "built-in" Reference Types:
Friday, October 01, 2004