Day Dreaming

"A daydream is a visionary fantasy experienced while awake, especially one of happy, pleasant thoughts, hopes or ambitions."[Ref:Wikipedia]

Day 2,3 - AJAX Continued...and Code...

***Disclaimer: I have got these information from varied sources and for some of them have been referenced directly from Sams teach yourself ASP.NET Ajax in 24 hrs.***
Ajax-enabled controls are ASP.NET server controls built by wiring the client components to the ASP.NET server controls.

Extenders are external objects that are wired with ASP.NET server controls to get the Ajax behavior, and script controls are server controls created as Ajaxenabled controls that specify both the server and client capabilities at the same place.

An extender is built by declaring a class that inherits from the base class ExtenderControl. This class should implement the interface IExtenderControl. Doing this registers the extender with the ScriptManager control.
AutoComplete is an ASP.NET Ajax extender that can be wired to any TextBox control, to display a suggested list of words in a pop-up panel with the prefix typed into the text box.

The ConfirmButton extender is used to attach itself to a Button control or any type derived from it, which prompts the user with a confirm dialog before submitting the page to the server. The DropDown extender attaches itself to a Label and Panel control to get a drop-down menu. The advantage of having this extender is that the Panel to which we are wiring up the extender can hold any type of server controls and not only link buttons. This provides the option to innovate with this extender.

Web Parts
Web parts are a set of server controls that are available in ASP.NET 2.0 that allow you to componentize your page into manageable sections. You can edit, move around holding the web part, change its settings at runtime, and can completely personalize your web page.
A web part page must have a WebPartManager and at least one web part zone. All the customization of content in the custom web part needs to be done dynamically from the code-behind file. The designer feature for customizing web parts is not available. Because you cannot customize the content in the web part from the design view, it is always suggested that you customize all the content of the web part in a user control or a custom control and add this control to the web part.

Client-side callbacks, a feature introduced by Microsoft in ASP.NET 2.0, allow controls to execute HTTP requests using JavaScript to obtain data on the server without posting the entire page.
For an Ajax operation to be performed, a control must implement the ICallbackEventHandler interface.
The PageRequestManager class belongs to the Sys.WebForms namespace and is responsible for managing the sequence of events for an asynchronous postback. When you mix callbacks and postbacks in your Ajax-enabled ASP.NET applications, you might encounter PageRequestManager
ParserErrorException. This error occurs when the response object is modified due to calls to Response.Write() and Response.Redirect() and usage of response filters and HttpModules.
ValidatorCalloutExtender is used in conjunction with a RequiredFieldValidator to validate the input data in a control. The following code uses this extender to validate the textbox txtProductName.
TextBoxWatermarkExtender is used to notify the user with a message in the textbox. The user needs to mention the textbox name in the attribute TargetControlID. When the textbox gets focus, the message is automatically wiped out.

http://www.box.net/shared/ga0dxmnjeg

DAY 1 : AJAX - Introduction and Components

AJAX
Why and What is ASP.NET Ajax?
**Disclaimer: I have got these information from varied sources and for some of them
have been referenced from Sams teach yourself ASP.NET Ajax in 24 hrs. **

AJAX (Asynchronous JavaScript) mainly allows you to perform partial updates to the page and also asynchronous postback which gives the users interactive and slick feel. Now, With AJAX, a JavaScript can communicate directly with the server, with the XMLHttpRequest object. With this object, a JavaScript can trade data with a web server, without reloading the page. You can find tutorial to AJAX at w3schools which takes you to all the basic concepts you need to know about AJAX. To provide partial page rendering we have two other options first using IFrame but it is a synchronous operation that causes the portion of the page to reload and flicker. And second, the client-side script needs to be written for hiding or showing the IFrame, when dynamic loading of a portion of the page is to be handled on an event. The second method using XMLHttpRequest object but isn’t the best, as the logic has to be moved from the server to client. Also, the browser incompatibility issues come into the picture when using the XMLHttp protocol. Thus using update panel and other ASP.NET Ajax is the best option.
How AJAX works?
Important blocks or services for which ASP.NET 2.0 has support:
- The Membership API - The Membership API in ASP.NET 2.0 enables you to manage the users and roles of an application.
- The Profile API -The ASP.NET 2.0 Profile API can be used to store profile information for both authenticated and anonymous users and make it available to the application for the user’s subsequent visits to the application.
- The Personalization API - The ASP.NET 2.0 Personalization API enables you to personalize your application seamlessly. You can use this API to customize the user profiles, themes, error pages of your application
The ASP.NET AJAX server extensions framework includes the following components:
- Application Services Bridge - This component is used to provide access to the application services available as part of ASP.NET 2.0 from client-side scripts. The basic services provided by this bridge include, but are not limited to, the following:
o User authentication using the Membership API
o Storage of user’s data using the Profile API
- The Web Services Bridge - The web services bridge is used to consume external web services from the client side in an Ajax-enabled web application. Web services have already been explained in the previous section. The web services bridge makes use of the JSON serializer, JavaScript proxies, and the .asbx files or the bridge files to call the web services.

ASP.NET AJAX Controls-
- Timer
- ScriptManager
- ScriptManagerProxy
- UpdateProgress
- UpdatePanel

Timer - Using the Timer control, you can set a timer for your web page. You can ensure that the web page can post back to the web server after a specified interval of time. You can use the Interval property of this control to set an interval in milliseconds, after which the web page will refresh itself. Once this interval elapses, the control fires a post back to the web server. This is how the mark-up code of a typical Timer control looks:


Script Manager – (Brain of an Ajax-Enabled Web Page) - Manages Microsoft ASP.NET 2.0 Ajax extensions script libraries and script files, partial-page rendering, and client proxy class generation for web and application services.
Script ManagerProxy - ScriptManagerProxy control enables you to add scripts and services that are specific to nested components. You should have a ScriptManager control in a web page that has a ScriptManagerProxy control, or else an InvalidOperationException error. If you need to register a script that is not part of Script manager control we can use Script ManagerProxy to add these scripts.



- Update Progress Control – (Displaying Progress Status During Partial Updates) - The UpdateProgress control can be used to display the progress status when using partial-page rendering in an Ajax-enabled ASP.NET web page.
...
- The UpdatePanel Control – (Facilitating Partial Page Updates) - The UpdatePanel control included as a part of the Ajax server extensions framework is used to update only a specified portion of the web page. This feature is what is commonly known as partial-web page rendering.

Setting the UpdateMode property to Conditional is advisable because it improves the performance of the web page considerably by sending only the data that is to be updated in the page.
A trigger is an event that causes the UpdatePanel to refresh its content. This event can be generated by any control in the form. There are two types of triggers:
- AsyncPostBackTrigger - The AsyncPostBackTrigger fires an asynchronous postback event on the UpdatePanel control. The child control’s postback of the UpdatePanel by default fires this trigger. There are two attributes associated with the AsyncPostBackTrigger: ControlID and EventName.
- PostBackTrigger - There might be situations where a button is clicked in an UpdatePane, and it requires the entire web page to be posted back. In such scenarios, we can go ahead with the PostBackTrigger. This trigger does not have an EventName property.
You can have one and only one ScriptManager control in your Ajax-enabled web page.

Restart...

Hey guys,firstly sorry but could not keep up to what I promised and let myself down.But really had other important things and was getting little too difficult to devote that much time. But sometime in future i will cover the remaining topics..So I have decided to restart with a different approach this time.

I have decided I will try to put topics more important for me to learn..I have decided to study some topics which are quite important and hopefully will help you all too. These are the topics I will try to cover -
1. ASP.NET AJAX
2. WCF
3. Web Services
4. WPF
5. SQL Reporting Services
6. Silverlight
7. XML/XSLT

These are the topics I decided not in that order and maybe will add more later. But these are more than enough right now for me to learn. I have decided that I will be giving each topic 3 days...and try to cover all the important points and aspects..
One of the things I have thought is to answer 3 questions - WHY ? WHAT ? HOW?
By answering these questions...for e.g AJAX...Why AJAX?....What is AJAX?...HOW AJAX WORKS?....I feel it will help to understand better...its just my point of view...As it is anyway impossible to cover every aspect I will cover the important concepts.
Okies so all said and done...I will be covering AJAX starting from today...23rd Feb to 25 Feb...and will then move with WCF or Web Services...Signing out...

“Failure is simply the opportunity to begin again, this time more intelligently.” - Henry Ford

Day -13 : Chapter 15 Introduction to Assemblies


Chapter 15 deals with Assemblies and their configuration.
Properties of assemblies -
·         Assemblies Promote Code Reuse
·         Assemblies Establish a Type Boundary
·         Assemblies Are Versionable Units
·         Assemblies Are Self-Describing
·         Assemblies Are Configurable
A .NET assembly (*.dll or *.exe) consists of the following elements:
·         A Win32 file header - The Win32 file header establishes the fact that the assembly can be loaded and manipulated by the Windows family of operating systems. This header data also identifies the kind of application to be hosted by the Windows operating system.
·         A CLR file header - The CLR header is a block of data that all .NET files must support  in order to be hosted by the CLR. In a nutshell, this header defines numerous flags that enable the runtime to understand the layout of the managed file.
·         CIL code - At its core, an assembly contains CIL code, which as you recall is a platform- and CPU-agnostic intermediate language. At runtime, the internal CIL is compiled on the fly (using a just-in-time [JIT] compiler) to platform- and CPU-specific instructions. Given this architecture, .NET assemblies can indeed execute on a variety of architectures, devices, and operating systems.
·         Type metadata - An assembly also contains metadata that completely describes the format of the contained types as well as the format of external types referenced by this assembly. The .NET runtime uses this metadata to resolve the location of types (and their members) within the binary, lay out types in memory, and facilitate remote method invocations
·         An assembly manifest - An assembly must also contain an associated manifest (also referred to as assembly metadata). The manifest documents each module within the assembly, establishes the version of the assembly, and also documents any external assemblies referenced by the current assembly.
·          Optional embedded resources - Finally, a .NET assembly may contain any number of embedded resources such as application icons, image files, sound clips, or string tables.
Private Assemblies - Private assemblies are required to be located within the same directory as the client application. The full identity of a private assembly consists of the friendly name and numerical version, both of which are recorded in the assembly manifest.
The .NET runtime resolves the location of a private assembly using a technique termed probing, which is much less invasive than it sounds. Probing is the process of mapping an external assembly request to the location of the requested binary file.
Shared Assemblies - The most obvious difference between shared and private assemblies is the fact that a single copy of a shared assembly can be used by several applications on a single machine. You cannot install executable assemblies (*.exe) into the GAC. Only assemblies that take the *.dll file extension can be deployed as a shared assembly.
<codeBase>  - Application configuration files can also specify code bases. The <codeBase> element can be used to instruct the CLR to probe for dependent assemblies located at arbitrary locations. If the value assigned to a <codeBase> element is located on a remote machine, the assembly will be downloaded on demand to a specific directory in the GAC termed the download cache. Given what you have learned about deploying assemblies to the GAC, it should make sense that assemblies loaded from a <codeBase> element will need to be assigned a strong name.
System.Configuration Namespace - The System.Configuration namespace provides a small set of types you may use to read custom data from a client’s *.config file. These custom settings must be contained within the scope of an <appSettings> element. The <appSettings> element contains any number of <add> elements that define a key/value pair to be obtained programmatically.
Machine Configuration File - The .NET platformmaintains a separate *.config file for each version of the framework installed on the local machine. If you were to open this file, you would find numerous XML elements that control ASP.NET settings, various security details, debugging support, and so forth. However, if you wish to update the machine.config file with machinewide application settings.

Day 8-12 : Chapter 14: Introduction to LINQ

Hey Guyz..really trailing my original plan and way lot to cover...As also I have been swamped with my other things..its really getting tough..but will give it my best..and go into overdrive mode now. Anyways..moving on with the book..we have next LINQ-
LINQ is Language Integrated Query. LINQ is a set of related technologies that attempts to provide a single, symmetrical manner to interact with diverse forms of data. As explained LINQ can interact with any type implementing the IEnumerable<T> interface, including simple arrays as well as generic and non generic collections of data.
The LINQ API is an attempt to provide a consistent, symmetrical manner in which programmers can obtain and manipulate “data” in the broad sense of the term. Using LINQ, we are able to create directly within the C# programming language entities called query expressions. These query expressions are based on numerous query operators that have been intentionally designed to look and feel very similar (but not quite identical) to a SQL expression.
LINQ query expressions is that they are not actually evaluated until you iterate over their contents. Formally speaking, this is termed differed execution.
When you wish to evaluate a LINQ expression from outside the confines of foreach logic, you are able to call any number of extension methods defined by the Enumerable type to do so. Enumerable defines a number of extension methods such as ToArray<T>(), ToDictionary<TSource,TKey>(), and ToList<T>(), which allow you to capture a LINQ query result set in a strongly typed container.
The OfType<T>() method is one of the few members of Enumerable that does not extend generic types. When calling this member off a nongeneric container implementing the IEnumerable interface (such as the ArrayList), simply specify the type of item within the container to extract a compatible IEnumerable<T> object.
You can also use Lambda operators for building queries. For e.g. –
var subset = currentVideoGames.Where(game => game.Length > 6).OrderBy(game => game) .Select(game => game);
General Syntax for LINQ Query - var result = from item in container select item;
LINQ query expressions can return any number of result sets, it is common to make use of the var keyword to represent the underlying data type. As well, lambda expressions, object initialization syntax, and anonymous types can all be used to build very functional and compact LINQ queries. More importantly, you have seen how the C# LINQ query operators are simply shorthand notations for making calls on static members of the System.Linq.Enumerable type.
As shown, most members of Enumerable operate on Func<T> delegate types, which can take literal method addresses, anonymous methods, or lambda expressions as input to evaluate the query.

Day 6,7 - Chapter 13: C# Language Features - Code

Holla Everyone,
I have attached code for the chapter. I will not be able to do for Chapter 12
but should be easy. Also two of the files have Main() so you need to remove one or
run one at a time. Cheers!
http://www.box.net/shared/ol5lun1y49
http://www.box.net/shared/0r7o52qfpj
http://www.box.net/shared/pucgu2op8l

Day 6,7 - Chapter 13: C# Language Features


This chapter deals with various other C# features and a relatively simple chapter. I will post the code for this chapter and for previous one together in the next post. Sorry but have been procrastinating little.
Implicity Typed Variables - C# 2008 includes implicitly typed local variable, now provides a new keyword  var, which you can use in place of specifying a formal data type and it will be assigned a type based on its initialization. It is illegal to use the var keyword to define return values, parameters, or field data of a type. Be very aware that implicit typing of local variables results in strongly typed data.

Automatic Properties - In C# we have automatic properties. Automatic property syntax -
public string PetName { get; set; }. We can also restrict access to automatic properties using protected and private properties. Also when we use automatic properties the variables are set to default values e.g. int to 0 and ref variable to NULL.

Extension Methods - Extension methods allow existing compiled types as well as types currently being compiled to gain new functionality without needing to directly update the type being extended. There are two conditions to be followed firstly the methods must be declared within a static class and methods must have this modifier.

Partial Methods  - Partial methods allows you to prototype a method in one file, yet implement it in another file. Restrictions on Partial methods –
• Partial methods can only be defined within a partial class.
• Partial methods must return void.
• Partial methods can be static or instance level.
• Partial methods can have arguments (including parameters modified by this, ref, or params—but      not with the out modifier).
• Partial methods are always implicitly private.

Object Initializer Syntax -  Using this technique, it is possible to create a new type variable and assign a slew of properties and/or public fields in a few lines of code. e.g.
 var yetAnotherPoint = new Point() { X = 30, Y = 30 }; - Default Constructor
var yetAnotherPoint = new Point(12,34) { X = 30, Y = 30 }; -Custom Constructor
We can also initialize collections in similar way.

Anonymous types - When you define an anonymous type, you do so by making use of the new var keyword in conjunction with the object initialization syntax. All anonymous types are automatically derived from System.Object E.g. –
var myCar = new { Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55 };
Anonymous types have following iterations –
• You don’t control the name of the anonymous type.
• Anonymous types always extend System.Object.
• The fields and properties of an anonymous type are always read-only.
• Anonymous types cannot support events, custom methods, custom operators, or custom
overrides.
• Anonymous types are always implicitly sealed.
• Anonymous types are always created using the default constructor.

Also, Since they derive from object they can have the methods of Object Class.Compiler-generated Equals() method makes use of value-based semantics when testing for equality (e.g., checking the value of each field for the objects being compared).

Day 5: Chapter 12: Indexes, Operators and Pointers

This Chapter is relatively simple and deals with Indexes,Operators and Pointers.

Indexer Methods - In its simplest form, an indexer is created using the this[] syntax. You can use intergers or even string to represent indexers. For e.g. following gives a function to represent using strings – public Person this [string name] {get {} set {}} We can also overload indexer methods , can have them on interfaces and also have multi dimensional arrays.
Operator Overloading- You can perform operator overloading . E.g Overloading an addition operator for a class point with two variables can be done–
public static Point operator + (Point p1, Point p2)
You can overload all kinds of operator’s unary, binary or comparison and other operators.
Custom Conversions - Also consider conversion between two classes which do not have a same parent. In order to perform this we can use either implicit or explicit conversion. Declare a explicit conversion using the following syntax-
public static explicit operator
public static implicit operator
Working with pointers - When you wish to work with pointers in C#, you must specifically declare a block of “unsafe code” using the unsafe keyword. Once you have established an unsafe context, you are then free to build pointers to data types using the * operator and obtain the address of said pointer using the ‘&’ operator.

The rest of the chapter mainly deals with '->' operator,fixed,sizeof and preprocessor directives. These last concepts have already been done in C and hence I am not going into details.

Delegates,Events and Lambdas and - Code

Hey Guys..I have not been keeping up with the pace i decided..so I am going to try and do better..I have not implemented Generic Delegates and Anonymous methods and Lambda Operators. Here are the links-

http://www.box.net/shared/ac7djgnr5z
http://www.box.net/shared/nyapktb7b5

Day 3,4 - Delegate,Events and Lambdas


Sorry..but really could not complete it on time. Also there are quite a few things that you may still require to read from other sources. Personally I found it difficult to complete this chapter.
Delegates- In essence, a delegate is a type-safe object that points to another method (or possibly a list of methods). E.g. This delegate can point to any method taking two integers and returning an integer.                      
public delegate int BinaryOp(int x, int y);
When the C# compiler processes delegate types, it automatically generates a sealed class deriving from System.MulticastDelegate. For the above example C# compiler will generate following code in bold are the items specified in declaration-
sealed class BinaryOp : System.MulticastDelegate
{
public BinaryOp(object target, uint functionAddress);
public int Invoke(int x, int y);
public IAsyncResult BeginInvoke(int x, int y,
AsyncCallback cb, object state);
public int EndInvoke(IAsyncResult result);
}
BeginInvoke() and EndInvoke() provide the ability to call the current method asynchronously on a separate thread of execution. Invoke() is perhaps the core method, as it is used to invoke each method maintained by the delegate type in a synchronous manner, meaning the caller must wait for the call to complete before continuing on its way. Further Multicast delegate derives from Delegate class which implements ICloneable and ISerializable. Also, it is not possible to directly derive from these classes.
A simple delegate example will be explained  in the code you can also determine NET delegates are type safe. Therefore, if you attempt to pass a delegate a method that does not “match the pattern,” you receive a compile-time error. Also,
Multicasting - When you wish to add multiple methods to a delegate object, you simply make use of the overloaded += operator, rather than a direct assignment. The Delegate class also defines a static Remove() method that allows a caller to dynamically remove a member from the invocation list.
Delegate Covariance - Given the laws of classic inheritance, it would be ideal to build a single delegate type that can point to methods returning either Car or SportsCar objects (after all, a SportsCar “is-a” Car). Covariance (which also goes by the term relaxed delegates) allows for this very possibility. Simply put, covariance allows you to build a single delegate that can point to methods returning class types related by classical inheritance.
In a similar vein, contravariance allows you to create a single delegate that can point to numerous
methods that receive objects related by classical inheritance. Consult the .NET Framework 3.5 SDK documentation
for further details.
Generic Delegates - We can also have Generic Delegates . For e.g. This generic delegate can call any method  returning void and taking a single parameter.
public delegate void MyGenericDelegate(T arg)

Events in ASP.NET  - You can declare a event using ‘event’ keyword when compiler processes the event keyword, you are automatically provided with registration and unregistration methods as well as any necessary member variables for your delegate types. These delegate member variables are always declared private, and therefore they are not directly exposed from the object firing the event and hence overcome the problem with delegates. To be sure, the event keyword is little more than syntactic sugar in that it simply saves you some typing time. Defining an event is a two-step process. First, you need to define a delegate that will hold the list of methods to be called when the event is fired. Next, you declare an event (using the C# event keyword) in terms of the related delegate. A C# event actually expands into two hidden public methods, one having an add_ prefix, the other having a remove_ prefix.
C# Anonymous Methods - It is possible to associate a delegate directly to a block of code statements at the time of event registration. Formally, such code is termed an anonymous method. You must terminate the method with a semicolon. Anonymous methods are interesting in that they are able to access the local variables of the method that defines them. Formally speaking, such variables are termed outer variables of the anonymous method.
C# 2008 Lambda Operator - Lambda expressions are nothing more than a more concise way to author anonymous methods and ultimately simplify how we work with the .NET delegate type. You can use the operator ‘=>’ and declare anonymous method after it.