Using web parts control with click and drag

The ASP.NET Web Parts control set is a group of components that work together to enable you to create Web pages on which end users can modify the appearance and behavior of the user interface (UI) directly from a browser. This overview covers the fundamental aspects of the Web Parts control set, including a description of the most frequently used and essential Web Parts components needed to create a Web Parts page.



Check at the following sample that you can move controls for a page layout by click and drag using web part control.




download sample code http://ifile.it/1vf4o2d

Ajax ModalPoupExtender

ModalPopup Demonstration

ASP.NET AJAX is a free framework for building a new generation of richer, more interactive, highly personalized cross-browser web applications. This new web development technology from Microsoft integrates cross-browser client script libraries with the ASP.NET 2.0 server-based development framework. In addition, ASP.NET AJAX offers you the same type of development platform for client-based web pages that ASP.NET offers for server-based pages. And because ASP.NET AJAX is an extension of ASP.NET, it is fully integrated with server-based services. ASP.NET AJAX makes it possible to easily take advantage of AJAX techniques on the web and enables you to create ASP.NET pages with a rich, responsive UI and server communication. However, AJAX isn't just for ASP.NET. You can take advantage of the rich client framework to easily build client-centric web applications that integrate with any backend data provider and run on most modern browsers.

Ajax MoalPoupExtender Sample










sample download
http://ifile.it/u96njyx

10th issue of Architecture Journal

The 10th issue of Architecture Journal has been published to subscribers and will soon be available to everyone else also.This issue talks predominantly about 'Composite Architecture' where articles discuss how to create an application by consuming services from different environment.This issues also has an interesting article 'Business Improvement Through Better Architected Software' which emphasize on bridging gap between business and technology people knowledge about each other work for creating better systems.
Architecture Journal Home : http://www.architecturejournal.net/

DotNet Partial Keyword

.NET languages now support distributed definition of classes which means a single class can be defined at multiples places/files and gets compiled into one during compilation. The keyword used to implement this feature is partial.

Consider the following code :
using System;
using System.Collections.Generic;
using System.Text;
namespace Architect.PartialClass
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Math.add(3,2));
Console.WriteLine(Math.subtract(3, 2));
}
}
partial class Math
{
public static double add(double num1, double num2)
{
return num1 + num2;
}

}
partial class Math
{
public static double subtract(double num1, double num2)
{
return num1 - num2;
}
}
}

The class definition of Math has been distributed into two but at compile time it gets aggregated into one and the client for the class sees it as a single class. The definition can be distributed to multiple files also. This feature provides advantage mainly in two scenarios :
  • In large projects separating a class over multiple files allows multiple programmers to work simultaneously.

  • When the code is generated the generated class can be enhanced without touching the generated code. This simplifies the maintenance. Partial keyword works on class, struct and interface definitions but its not available on delegate or enumeration declarations.

Delegates And Anonymous Methods

A delegate is a type which stores reference to a method. It is much similar to function pointers in C and C++ but delegates are type-safe and secure.
Once a reference is stored in delegate it behaves very similar to the referenced method. Parameters can be passed and values can be returned in a similar fashion.
Any method that matches the delegate's signature, which consists of the return type and parameters, can be assigned to the delegate.
There are mainly three ways of assigning method references to delegates :

  • Named static methods
  • Named Instance methods
  • Anonymous methods : Supported from CSharp 2.0 onwards.

Consider the following working program:

1:using System;
2: using System.Collections.Generic;
3: using System.Text;
4:
5: namespace Architect.Delegates
6: {
7: class Program
8: {
9: delegate void Del(string name);
10: static void Main(string[] args)
11: {
12: /* Named Static Method */
13: Del handler;
14: handler = SampleClass.StaticMethod;
15: handler("Architect");
16:
17: /* Named Instance Method */
18: SampleClass sc = new SampleClass();
19: handler = sc.InstanceMethod;
20: handler("Architect");
21:
22: /* Anonymous Method supported from C# 2.0 */
23: handler = delegate(string name)
24: {
25: System.Console.WriteLine("Hi " + name + " : A message from the anonymous method."); 26: };
27: handler("Architect");
28: }
29: }
30:
31: class SampleClass
32: {
33: public void InstanceMethod(string name)
34: {
35: System.Console.WriteLine("Hi "+name+" : A message from the instance method.");
36: }
37:
38: static public void StaticMethod(string name)
39: {
40: System.Console.WriteLine("Hi " + name + " : A message from the static method.");
41: }
42: }
43:
44: }
Line 9 shows declaration of the delegate.
Line 12 to 15 shows implementation & execution using named static method.
Line 17 to 20 shows named instance methodLine 22 to 27 shows anonymous method implementation.

OUTPUT :
Hi Architect : A message from the static method.
Hi Architect: A message from the instance method.
Hi Architect : A message from the anonymous method. Delegates are extensively used to implement callback methods while designing asynchronous systems.

Anonymous delegates helps in avoiding creation of a separate method.

Static Classes

In .NET Framework 1.x, Static Classes are created by defining a class with a private constructor with one or more static members so that instance of the class cannot be created using new operator.

In .NET Framework 2.0 the need for such a private constructor is avoided by using a static keyword along with the class definition. Static classes are sealed and therefore cannot be inherited. Static classes cannot contain a constructor, although it is still possible to declare a static constructor to assign initial values.

using System;
using System.Collections.Generic;
using System.Text;
namespace Architect.StaticClasses
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(StaticClass.getName());
Console.WriteLine(StaticClass.getName());
Console.WriteLine(StaticClass.getName());
}
}
static class StaticClass
{
private static string name;
static StaticClass()
{
name = "Architect";
Console.WriteLine("In Constructor");
}
public static string getName()
{
return name;
}
}
}

Creating a context menu item for folder

I remember in .NET 1.0 sdk there used be a sample which demonstrated how to modify registry through CSharp. By doing so it used to add an item into the context menu of folders in windows explorer. The best thing about that item was that it can be used to open a command window directly into that folder which is very useful if you work with lot of console applications.
Well, i couldn't find it in .NET 3.0 sdk samples but managed to find how to write such a sample.

Here is the code which is very simple and demonstrate the power of CSharp.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
namespace RegistryProgram
{
class Program
{
static void Main(string[] args)
{
try
{
Registry.ClassesRoot.CreateSubKey("Directory\\shell\\CmdWindow");
RegistryKey rk = Registry.ClassesRoot.CreateSubKey
("Directory\\shell\\CmdWindow\\command");
rk.SetValue("","cmd \"%1\"");
}
catch(System.Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
}
}
}