September 28, 2005

Best approach for a 3 tier application ?




















I have read so many articles went through so many blogs, had discussions with professional developers & this is what i got finally,(remember this is not about tierd architecture , this is about passing the data thorugh tiers..) any ideas???

September 27, 2005

Discussion About Microsoft Patterns & Practices

we just thought to have discussion about microsoft patterns & practices if you guys are interested go head & publish your thoughts to this post http://mahasen.blogspot.com/2005/09/talking-about-microsoft-patterns.html

September 26, 2005

Share your videos with Google

One of my colleagues just showed me another googles invention. Its still in beeta. But guys its really worth. You can share your videos over the internet..more.... Goto: http://video.google.com

September 23, 2005

Custom Objects with Web Services

Web Services are not .net specific. Most of them might think its something Microsoft invented. What Microsoft have done is they implemented a common standard. To create a web service in .net is really easy. But you should understand the concept behind it. You can find the public web services which available through Microsoft UDDI service.(http://uddi.microsoft.com/visualstudio/ )

So today im going to explain how to return a custom object through web service. I will explain the scenario from a simple diagram.( banks needs a valid telephone number to issue a credit card its a fact)




















In this scenario Telephone Company is offering a web service to its partners to get the customer just by supplying customers telephone number.

Customer class:

public class Customer
{
public Customer()
{
//
// TODO: Add constructor logic here
//
}

string _name;
string _age;
string _company;

public string Name
{
get{return _name;}
set{_name = value;}
}

public string Age
{
get{return _age;}
set{_age = value;}
}
public string Company
{
get{return _company;}
set{_company = value;}
}
}

GetCustomer web service method which returns the customer object

[WebMethod]
public Customer GetCustomer()
{
//can be perform any database functions

Customer customer = new Customer();
customer.Name = "Ludmal de silva";
customer.Age = "25";
customer.Company = "E-Solutions";

return customer;
}


Now we can use this web service by simply adding a web reference to our project.(you guys should know how to add a web reference its really simple).

Finally you can get the customer object which returns from the web service. Code below.

//Customer object
CustomerService.Customer customer = new CustomerService.Customer();

//CustomerService object
CustomerService.Service1 myCustomerService = new CustomerService.Service1();

///Get the customer from the WebService
customer = myCustomerService.GetCustomer();

//Assigning the values to the UI
this.Label1.Text = customer.Name;
this.Label2.Text = customer.Company ;
this.Label3.Text = customer.Age ;

What I was trying to do is to give a basic idea about web services & to use the custom object with web services. I highly appreciate comments. (my writing skills might be poor...) But all the questions /comments are welcome.

September 22, 2005

Custom DataGrid with client side behavior

while i was digging into the massive microsoft MSDN site i found this interesting article about the data grid. Never thought a datagrid can do this much. Check the article at http://msdn.microsoft.com/msdnmag/issues/04/01/CuttingEdge/default.aspx im working on a article to show how to return a custom object through a web service. I will publish it tommorow. So stay tuned. ;)

September 21, 2005

Power of CSS

You will be amazed of the CSS possibilities. It can completely change the page's layout with no tables at all. CSS is a really a powerful technology for the UI designers. I just went through a site today (one my colleague refer me to this site) its dedicated site to CSS stuff...really cool. I think UI designers should know the real beauty of CSS for designing spectacular sites.
http://www.csszengarden.com/

September 20, 2005

Using Web User Control

Note: Recommend Audience - Asp.net Beginner

Web user control is playing a major role in asp.net development. Its hardly possible to develop a application without web user controls. But most of developers are not using it properly. In this article I just thought to share some powerful features of web user control. Microsoft .Net framework is fully object oriented implementation. So we have to take advantage of it. We can learn lots of things by looking at the Microsoft class library. So lets start simple sample to show proper use of Web user control.

Scenario: We have to create 3(might be more) Registration forms in different formats. But the Mailing Address section is always stays the same. We need to accomplish this in minimum effort with a Web User Control in OOP manner.

Solutions: So lets start creating simple Web User Control name AddressUI;






In code behind of the AddressUI insert the below code

//AddressUI Properties
public string Street1
{
get {return this.txtStreet1.Text ;}
set {this.txtStreet1.Text = value;}
}

public string Street2
{
get {return this.txtStreet2.Text ;}
set {this.txtStreet2.Text = value;}
}
public string City
{
get {return this.txtCity.Text ;}
set {this.txtCity.Text = value;}
}
public string Country
{
get {return this.txtCountry.Text ;}
set {this.txtCountry.Text = value;}
}
public bool ContactMe
{
get {return this.chkContactMe.Checked ;}
set {this.chkContactMe.Checked = value;}
}


Now you can use this AddressUI control in any page u wanted. Giving u easily maintainable UI. Let me show you how u can use this control in your ASP.net pages.

Drag & drop the control into the page. You can access the controls property. Check the below code.

Declare the AddressUI control

protected AddressUI AddressUI1;

then access its properties, Add this code to a button click event.

Response.Write(AddressUI1.City + AddressUI1.Country );


your done. You can assign its properties to another objetecs properties.. no hassle doing Page.FindControl & no casting at all.

The Hundred Greatest Theorems

check this out The Hundred Greatest Theorems

IE Developer Toolbar

I tried MSN tool bar with the tabs option. trust me its damn lazy work. They just wanna do something ... when ever we maximize /minimize the IE window the page get refreshed which makes me pissed off. Sometimes the IE window get stuck which makes it even worse. So personally I hate MSN toolbar. I rather like Firefox tab options. Since were doing asp.net stuff , most of our customers are using IE we have to stick to it. But its not a must..;) anyhow Microsoft has released toolbar for Internet Explorer 6. itsbasically designed to make developing and previewing websites in IE even easier. I think its really good for web designers to see the site layout & so forth. It will show you the image info, site layout info & even we can validate the HTML , CSS etc through W3C site. You can pinned the Developer toolbar to the Internet Explorer browser window or floated separately.

Download IE developer Toolbar

To list some of the features:
· View HTML object class names, IDs, and details such as link paths, tab index values, and access keys.
· Outline tables, table cells, images, or selected tags.
· Validate HTML, CSS, WAI, and RSS web feed links.
· Display image dimensions, file sizes, path information, and alternate (ALT) text.
· Immediately resize the browser window to 800×600 or a custom size.
· Selectively clear the browser cache and saved cookies. Choose from all objects or those associated with a given domain.
· Choose direct links to W3C specification references, the Internet Explorer team weblog (blog), and other resources.
· Display a fully featured design ruler to help accurately align objects on your pages.

September 19, 2005

Blog search by Google

Google has unveiled a website that lets people search web journals or blogs. Try your self: http://blogsearch.google.com/

Word verification for comments

i had to put a word verification for comments bcoz of the number of spam comments im getting. So those who are submitting comments accept my regret & use word verification.

September 16, 2005

Hotmail will be replacing by Microsoft Mail

I created my first email with Microsoft Hotmail. It was the best webmail provider in that time. But i didnt log in to my hotmail since 1998. how pity...I'm currently using gmail as my default webmail. I defently like the simple design & the power of ajax. Anyhow microsoft didnt compltly gave up the hotmail. Their fighting back with thier new Microsoft Mail. Its still in beeta only released to small number of beeta testers & for the microsoft employees. You can see some screenshots below. Google Microsoft battle continues....

Twenty-Eight Design Aphorisms

1. Everything in life is ephemeral, don’t expect anything you design to live forever.

2. Use technology, don’t let it use you.

3. Be aware of what you make and what it says, because people live and die through all of the images we create.

4. We need more teamwork.

5. Have your cake and eat it too; participate in design “research.”

6. Have a backup plan.

7. Designers are not monkeys, they do not merely articulate.

8. New ideas are made every single day; unless you repeat yourself, it’s new. Don’t worry about whether or not the person next to you is doing it, or will do it.

9. Trust no one. No matter how original your idea seems, somebody else is looking to do it better, and probably cheaper.

10. Keep your enemies close. (See number 9.)

11. Media allegiance spells limitation. Think first, then choose what tools to use.

12. There’s nothing wrong with design that looks like art.

13. There’s nothing wrong with art that looks like design.

14. Think holistically.

15. Work in a style that maximizes your performance and well being.

16. Appreciate your audiences’ needs and team members’ skills.

17. Establish objectives prior to form.

18. Brainstorm. Fail frequently. Enjoy the element of play.

19. There are no truisms.

20. A connoisseur of design is not a designer.

21. Design history is not a chronicle of style; you cannot truly critique design unless you fully understand its history.

22. Ideology, thought, and agenda are as important as aesthetics.

23. Design without ego.

24. Statements like “Designers Don’t Think” are short-sighted at best.

25. There is always more than one solution.

26. There will always be revisions.

27. The entire process of design is its essence. Without process, we are left with merely style and solutions.

28. Aesthetic biases are and are not the purest form of design.

September 15, 2005

Document your code.

Since we're doing some RAD stuff nobody got time to comment their code. But commenting code will be really helpful once we get used to it. If more than one developer is working on the same file it will be advantageous to that developer. As far as I concern every developer should comment their code. We can automatically generate a comments document using a third party tool or by using the Visual Studio. Every method we write should be documented/ commented. Its really helpful to the client developers. If were building a library you must comment your code coz thats the only way a client developer can understand easily how to use the library. Most of the developers already know how to use Microsoft comments.


/// <summary>
/// Gets the users age
/// </summary>
/// <param name="name">username</param>
/// <returns>age</returns>

public int GetAge(string name)
{
return 26;
}


I will show you how to document your code using Visual Studio. You can completely generate a standard documentation from the VS ;)

Click on the Tools > Build Comment Web pages >

Then the Build Comment dialog box will appear, you can select the solution that you want to document, give the path & then press ok. Youre done. You will get a nice documentation for your project. For vb developers you can download add in for xml style comments from this url. http://www.gotdotnet.com/team/ide/#original

September 13, 2005

Whidbey and Yukon in November 7

Microsoft is set to release Whidbey and Yukon in November 7. So stay tuned & develop more powerful applications than today. Add this http://blogs.msdn.com/pdc/rss.aspx rss feed to staty updated with the PDC 2005. PDC is more focusing on Windows Vista. I still couldn’t try vista. It’s supporting Sinhala Unicode characters. Cool isn’t it.

September 8, 2005

Ajax with Custom objects

Ajax (Asynchronous JavaScript and XML) is recently become so popular with the google's gmail release. For .net we have an open source Ajax.net library. (for more info goto http://sourceforge.net ) So today I want to explain some cool stuff which we can do using ajax.net. We can now use custom objects with ajax. the best way to explain is from a example.. so lets go to the code.. what we're trying to do is to return a custom object & bind its properties to a HTML controls. We can instantiate the object from the server side code & pass it to the client side. See how simple.. no Postbacks at all ...below is the complete code..ohh I almost forget something, to use custom objects with ajax we must make the object serializable. So don't forget the serializable attribute.(what is does is serializing/deserializing the object ) ok enough talking, i want to show you the example.. (need to keep this article short as possible to improve readability ?)

First add the HttpHanlders to the webconfig file .

<httpHandlers>      
<
add verb="POST,GET" path="ajax/*.ashx"           
type="Ajax.PageHandlerFactory, Ajax" />
</
httpHandlers/>

Then well create a simple customer class.

            [Serializable]
            
public class Customer
             {
            
            
string _name;
            
string _address;
            
int _type;
            
            
public string Name
             {
            
get{return _name;}
            
set{_name = value;}
             }
            
            
public string Address
             {
            
get{return _address;}
            
set{_address = value;}
             }
            
            
public int Type
             {
            
get{return _type;}
            
set{_type = value;}
             }
            
            
public Customer(string name, string address, int type)
             {
            
this._name = name;
            
this._address = address;
            
this._type = type;
             }
             }

            
            In the sample webform1.aspx page write the below method. This will return the customer object. You perform any logic here to return the customer object. But for me im just simply instantiate the object.

   [Ajax.AjaxMethod()]
   public Customer GetCustomer()
   {

   //You can do some database logic here to get the customer object0
   Customer customer = new Customer("Microsoft","Redmond",1);
   

   return customer;
   } 

   
   
To use this method in the client side we have to register class(In this case the page itself) in the Page_Load event.

Ajax.Utility.RegisterTypeForAjax(typeof(WebForm1));

Ok were almost done. Simply create a JavaScript function to get the values from the object.

function BindCustomer()
{
var customer = WebForm1.GetCustomer().value; document.getElementById('lblName').innerText = customer.Name; document.getElementById('lblAddress').innerText = customer.Address; document.getElementById('lblType').innerText = customer.Type;
}

Of course you have to do the html part. (Add some html controls to the page) .so have fun with ajax. Happy coding... & stay tuned for my next post

September 7, 2005

Google's secret Lab

google has a secret search quality lab that utilizing human testers with the goal of improving search quality. They are testing the quality of the search results from the humans all over the world. The're main goal seems to avoid spam & to get the right site on top. You can find more info here
http://www.searchbistro.com/index.php?/archives/19-Google-Secret-Lab,-Prelude.html

September 2, 2005

ASP.Net low level view

Ever thought of ASP.NET low level process..?? We shouldn't know but its worth to take look at the ASP.NET pipeline. ASP.NET is far away from the classic ASP apps. ASP.NET is easier & far superior than the classic ASP. Typically a .net web developer should know how to interact with objects & events in which ASP.NET high level interface provides. The entire ASP.NET engine built in managed code. ASP.NET is request processing engine. It takes the incoming requests & passes to its internal pipeline to an endpoint where a client developer can attach code to process that request. Request with .aspx extension will move to the appropriate HttpHandler by the aspnet_isapi.dll. When the request comes in it process by the ASP.NET runtime. Depending on the extension it routes the request to an appropriate handler that is responsible for picking the request. Likewise we can program to any type of extensions with our own custom Httphandler. To get a clear picture of the underlying process take a look at the image below.