Feb 28, 2007

Operator Overloading in VB.NET


We can overload the
I got good link having example how to overload the Operator in VB.Net.

Have a look at this delicious.

Formating output in C#


I come across blog which is very useful to format our output using string.Format() in C#

I have delicious on C#

Feb 23, 2007

Personalise Your Site's Bookmark [Adding icon in addressbar]


I had requirement in which I have to add icon in addressbar, its really simple.

You just have to create one icon file Favicon.ico

Now how to Create a "Favicon.ico" File?

· Create an image 16X16 pixels in size. Yes, it is really small and you can't really draw much in it. You should also restrict yourself to the standard Windows 16 colours, although I suspect that 256 colours will work fine.
· If you like, you can also create a 32X32 pixel icon, which will be scaled to size for the Favorites menu and the location bar. You can even put both 16X16 and 32X32 pixel icons into the same icon file. Windows will use the former for its menus and the latter when the user opens up a folder that is set to display large icons. It's probably not really necessary to do this if you can't be bothered.
· Save the image as an ICO file (named "favicon.ico", of course).
Upload it to your website. You don't need to upload one to every directory of your site if you don't want to waste space - simply put it in your root directory and IE will apparently locate it eventually. You can also upload it into your images directory, but you will need to modify your web pages if you do. See later in this article for more information

Helping the Browser Locate the favicon.ico file
If you have placed your favicon.ico file in a location other than the current web directory (relative to your web page) or the root directory, you have to help your visitors' browser locate the favicon file by specifying it with a tag like the following in the <head> section of your web page.

<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />

Feb 21, 2007

Some hints for developing High-Performance ASP.NET Applications

I observed the following points to be kept in mind while developing application in ASP.NET

· Disable session state when you are not using it.
· Use Page.IsPostBack to avoid performing unnecessary processing on a round trip
· Save server control view state only when necessary
· Do not rely on exceptions in your code [Avoid try, catch block]
· Use the common language runtime's garbage collector and automatic memory management appropriately [try to avoid having objects with Finalize methods] see Automatic Memory Management.
· Use the HttpServerUtility.Transfer method to redirect between pages in the same application
· Use early binding in Visual Basic .NET or JScript code [Include a Strict attribute in the @ Page directive or, for a user control, in the @ Control directive]
· Use SQL Server stored procedures for data access
· Use the SqlDataReader class for a fast forward-only data cursor [SqlDataReader class offers higher performance than the DataSet class]
· Choose the data viewing mechanism appropriate for your page or application [DataGrid Web server control can be a quick and easy way to display data, but it is frequently the most expensive in terms of performance.]
· Cache data and page output whenever possible
· Be sure to disable debug mode
· Enable authentication only for those applications that need it
· Consider disabling AutoEventWireup for your application
· Remove unused modules from the request-processing pipeline

I also have delicious on ASP.NET Performance and optimization

AutoEventWireUp is hitting the performance!!!

Yes its true,

Consider disabling AutoEventWireup for your application.

Setting the AutoEventWireup attribute to false in the Machine.config file means that the page will not match method names to events and hook them up (for example, Page_Load).

If page developers want to use these events, they will need to override the methods in the base class (for example, they will need to override Page.OnLoad for the page load event instead of using a Page_Load method).

If you disable AutoEventWireup, your pages will get a slight performance boost by leaving the event wiring to the page author instead of performing it automatically.

Problem after converting to C#


I was converting my vb project to C# using converter. This tool is really helpful to me for converting my vb application.

It converts successfully, but i notice some points that needs to be checked after done conversion

· Ensure that each page must have C# as language
· Container.DataItem("Field") must converted to DataBinder.Eval(Container.DataItem,"Field")
· Check for the inline code

Feb 18, 2007

Difference between properties and method [Microsoft Design]

In most cases, properties represent data, and methods perform actions. Properties are accessed like fields, which makes them easier to use. If a method takes no arguments and returns an object's state information, or accepts a single argument to set some part of an object's state, it is a good candidate for becoming a property.

Properties should behave as if they are fields; if the method cannot, it should not be changed to a property. Methods are preferable to properties in the following situations:
· The method performs a time-consuming operation. The method is perceivably slower than the time it takes to set or get a field's value.
· The method performs a conversion. Accessing a field does not return a converted version of the data it stores.
· The "Get" method has an observable side effect. Retrieving a field's value does not produce any side effects.
· The order of execution is important. Setting the value of a field does not rely on other operations having occurred.
· Calling the method twice in succession creates different results.
· The method is static but returns an object that can be changed by the caller. Retrieving a field's value does not allow the caller to change the data stored by the field.
· The method returns an array.

I also have delicious on Microsoft Design [Use properties where appropriate]

Feb 16, 2007

Static holder types should not have constructors [Microsoft.Design]

I created class which has all the static methods, look at the following code there is no compilation error

public class ServerController
public static ArrayList GetHttpServers() { ... }
public static ArrayList GetXmlRpcServer() { ... }

But as fas as performance concern this is wrong!! Why?

Warning : Remove the public constructors from 'ServerController'.

But i havnt declare any constructor!!

I can explain you, the default constructor is created automatically so how to avoid this message.

Two ways, 1) Make default constuctor as private or 2) Or make your class static.

Now look at class again

public static class ServerController
public static ArrayList GetHttpServers() { ... }
public static ArrayList GetXmlRpcServer() { ... }

Simple right?

I also have delicious on Microsoft Design

Feb 15, 2007

Pass arguments what requied [Microsoft.Design]

I come across one situation where I have to set visibility of panels, and I have to that code frequently so I created on function which accepts panels as argument…

public static void SetNoDataFound(Panel pnlToShow, Panel pnlToHide, Label txtToShowMessage, string strMessage)
pnlToShow.Visible = true;
pnlToHide.Visible = false;
txtToShowMessage.Text = string.Format(DefaultCulture, GetNoDataFoundMessage, strMessage);

Strange!! But it’s simply true. If you are using property of parent object then why should you pass child object?

So here is modified version of code, you can say optimized!!

public static void SetNoDataFound(Control pnlToShow, Control pnlToHide, Label txtToShowMessage, string strMessage)
pnlToShow.Visible = true;
pnlToHide.Visible = false;
txtToShowMessage.Text = string.Format(DefaultCulture, GetNoDataFoundMessage, strMessage);

You can see the change, instead of Panel I write Control which is parent of Panel.
This means that at the time of calling this function it’s just sent the reference of Control not Panel :)

Compare two objects!!!

Use IComparer Generic Interface.

This interface provides

public int Compare(object x, object y)

you overiddes this method and implement yours, so simple right?


public class MyComparer : IComparer
public MyComparer() { }

public int Compare(object x, object y)
return DateTime.Compare(((MyClass)x).EntryDate, ((MyClass)y).EntryDate);

A delicious related to this topic!

Feb 14, 2007

Find text in Stored procedure


One interesting query I found which searches word in stored procedures and returns the name of procedure which contains that word
FROM sysobjects o
INNER JOIN syscomments c ON ( =
xtype = 'P' and category = 0 and c.text LIKE '%SearchWord%'

Sqlserver Date and time functions

A delicious for sqlserver date and time functions

JavaScript Verifier (Verify your Javascript)

Website for Verifying your javascript

It reports lots of small mistake which could be avoided and make javascript perfect...

This will help you to use your application in multiple browser

Feb 10, 2007

Trackback problems!!


i had implemented incomming trackback handler.

following may be helpful in implementation.