Tuesday, July 14, 2009

AJAX Control Toolkit

Calendar Extender

Calendar Extender of AJAX Control Toolkit for ASP.Net 2.0 frameworks provides the AJAX based client side functionality to pick the date from popup calendar extender control. You can customize the date format and also the style of calendar user interface using CSS. AJAX Calendar control sets the date clicked by the user into the associated Textbox.

Drag and Drop the calendar extender on the AJAX enabled aspx page. Here AJAX enabled aspx page means the web page having AJAX script manager on the top of the page. Calendar extender will just show the placeholder in design view of web page. Next drag and drop the standard TextBox server control. By default Textbox will have its ID as TextBox1 and Calendar extender’s ID as CalendarExtender1. In the next step adjust the following properties of Calendar extender according to your requirement:

Animate: Accepts value as true/false. If true then it animates the calendar actions.

FirstDayOfWeek: It is an enumerator type collection that specifies to display the first of week in the calendar at runtime.

Format: You can set the different date formats using date formats e.g.: MMM dd, yyyy; MMM DDD dd, yyyy.

PopUpButtonID: You can specify the ID of image control, button control or linkbutton control to popup the calendar control. If PopUpButtonID is not specified then Calendar control popups when associated textbox gets focus.

PopUpPosition: This property sets the position of calendar control, that where should it appear such as BottomLeft of textbox, BottomRight, TopLeft, TopRight, Right or Left.

SelectedDate: You can specify the default date for the Calendar using SelectedDate Property. Calendar control initializes with the specified date.

TargetControlID: Specify the target TextBox ID in this property that will display the user selected date in the specified date format.

How to Use Calendar Extender on Web Page

When Calendar control appears it displays the default view having Month Name and Year at Top along with left and right arrow. You can use left and right arrow to shift to previous or next month regarding the current day view.

If you will click on the Month Name and Year at top then calendar control will switch to the month view. You can select the month of year specified for the calendar control or current year by default.

If you will click on the Year at top then the Calendar control will switch to the year view.

Thursday, January 8, 2009

Dotnet Questions

Differences between .net 1.1 and 2.0

ASP.NET 2.0 introduces a lot of new features. Some of this features aim to simplify the problems faced using the earlier versions and some features are introduced to provide lot of new facilities.
The most important features that are incorporated in ASP.NET 2.0 are:

(a) Master Pages

Master pages are introduced to remove one of the most important deficiencies of earlier version of ASP.NET. One thing that has become apparent in the earlier version of ASP.NET is the lack of architecture for applying a consistent look and feel. In earlier version of ASP.NET whenever a developer wants to replicate a common functionality of a web page in other pages, the most possible options he uses is creating a user control and then replicate the functionality in other pages.
ASP.NET 2.0 aims to solve this problem by introducing the concept of Master pages. First the developer needs to define a master page containing the content that he wants to appear on other pages and then use the ContentPlaceHolder controls to define the locations where the sub pages can plug in the content of their own. The he has to build the sub pages - .aspx pages – that reference the master using directives like this one:

In addition, an application can designate a default Master Page in web.config as shown here:


(b) PreCompilation

By default, ASP.NET web pages and code files are compiled dynamically when a first request is made to the page. After the initial compilation, the compiled pages is cached; the cache is used to satisfy the subsequent requests for the same page. Even though this approach is flexible, when the page is requested for the first time, it requires a bit of extra time to compile the code. You can avoid this overhead by leveraging a new feature known as precompilation; by using this feature, you can compile an ASP.NET web site before making the web site available to the users.

(c) Sharing code in the application

In earlier version of ASP.NET, if you were to reference a reusable component from your dot net application, you had to compile the assembly and place it in the bin folder (or place it in the GAC) of the web application. But now with ASP.NET 2.0, creating a reusable component is very simple and straightforward. All you need to do is to create a component in a pre-defined subdirectory called code. Any component placed in this directory will be automatically compiled at runtime into a single assembly. This assembly is automatically referenced and will be available to all the page in the site.

(d) Themes and Skins

ASP.NET 2.0 introduces the concepts of Themes and Skins by means of which the look and feel of the web pages can be enhanced to a great extent to make them visually catchy and attractive.
A skin is a set of visual attributes applied to a control type. A theme is a collection of skins. There are a lot of predefined themes in ASP.NET 2.0. One can use it by using the following line of code:

The page directive’s Them attribute declaratively applies a theme to a page. Themes can also be applied programmatically using the page class’s Theme property


Difference between VB.NET and C# ?

Well this is the most debatable issue in .NET community and people treat there languages like religion. Its a subjective matter which language is best. Some like VB.NET’s natural style and some like professional and terse C# syntaxes. Both use the same framework and speed is also very much equivalents. But still let’s list down some major differences between them :- Advantages VB.NET :-

√ Has support for optional parameters which makes COM interoperability much easy. √ With Option Strict off late binding is supported.Legacy VB functionalities can be used by using Microsoft.VisualBasic namespace.

√ Has the WITH construct which is not in C#.

√ The VB.NET part of Visual Studio .NET compiles your code in the background. While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger.

Advantages of C# :

√ XML documentation is generated from source code but this is now been incorporated in Whidbey.

√ Operator overloading which is not in current VB.NET but is been introduced in Whidbey.

√ Use of this statement makes unmanaged resource disposal simple.

√ Access to Unsafe code. This allows pointer arithmetic etc, and can improve performance in some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is lost (as the name implies).This is the major difference that you can access unmanaged code in C# and not in VB.NET.

What is GAC ?

Twist :- What are situations when you register .NET assembly in GAC ?

GAC (Global Assembly Cache) is used where shared .NET assembly reside. GAC is used in thefollowing situations :-

√ If the application has to be shared among several application.

√ If the assembly has some special security requirements like only administratorscan remove the assembly. If the assembly is private then a simple delete ofassembly the assembly file will remove the assembly.

Note :- Registering .NET assembly in GAC can lead to the old problem of DLL hell,where COM version was stored in central registry. So GAC should be used when absolutelynecessary.


How to add and remove an assembly from GAC?

There are two ways to install .NET assembly in GAC:-

√ Using Microsoft Installer Package. You can get download of installer fromhttp://www.microsoft.com/.

√ Using Gacutil. Goto “Visual Studio Command Prompt” and type “gacutil –i(assembly_name)”, where (assembly_name) is the DLL name of the project