Wednesday, June 30, 2004

VJs Tip Of The Day - June 30th 2004

Installer for Globalization

If you have different versions of your web application built for different languages and you have seperate resource files for each language when you need to deploy your application according to the language settings of the server then in that case make an Installer that has Custom Action to install only location-specific files...

Tuesday, June 29, 2004

VJs Tip Of The Day - June 29th 2004

allowOverride Attribute

If you have a common server where you are going to host your website and you do not want anyone to override your configuration settings after the site is deployed then within your web.config file, use <location> tag and set allowOverride attribute to false....

Monday, June 28, 2004

VJs Tip Of The Day - June 28th 2004

Virtual/Abstract members of a class

Virtual or Abstract members of a class cannot be private... Well just think, if you make them private why would you make them virtual or abstract anyways...:-)


PS: This tip is suffering from "Case of Monday" syndrome... :-)

Friday, June 25, 2004

VJs Tip Of The Day - June 25th 2004

Interface vs Abstract classes

For Abstract class one method of the class must have an abstract method that means, it may have concrete methods...

Various access modifiers such as abstract, protected, internal, public, virtual, overrides etc are not useful in case of Interface but they are in case of Abstract classes

Class implementing Interface has to implement all the methods of the Interface, this is not required in case of Abstract classes

Interfacescannot have constructors and destructors like the way Abstract classes can...

Interface cannot contain a static method whereas an Abstract class can have...

There are few more points which I can recollect but I think that this is enough for a tip... If anyone needs more info do write back to me... :-)


* pure virtual method is a method which has just definition but not implementation...

PS: Many of us work on weekends, I don't think (current thought!!) that its a good practice doing that, atleast if you are being guaged on the basis of your willingness to work on weekends then its surely very bad... I am trying to start a movememt to abolish this social evil of working on weekends, so no tips on weekends...:-)
BONUS TIP: Spend time with your family this weekend... :-)

Thursday, June 24, 2004

VJs Tip Of The Day - June 24th 2004

Call to Static Methods

You cannot call static method of a class using the object of the class*... You would have to call it using the Class name itself..
eg.You cannot call base class's static method using base.StaticMethod(); that shall result into an error...

the way you do it is:
//Class having Static Method
public class MyClass
{
public static string StaticMethod()
{
return "Vishal_Joshi@MVPs.org";
}
}

//Class using Static Method
public class ClientClass
{
public string GetHelpLineEmailId()
{
return MyClass.StaticMethod();
}
}

* This is applicable only to C# in case of VB.Net you can access static methods even using the object of the class... (This is what happens to a C# fan.... Thanks to Jacob Cynamon, MS and Kathleen Dollard, MVP for reminding... )

Wednesday, June 23, 2004

VJs Tip Of The Day - June 23rd 2004

Static Members of a class

A static member of a class can be accessed without creating an instance of the class... Everyone knows this right!! so what next...??
A static member cannot be marked as abstract or virtual, trying to do so will result into an error...
Inside a static member you cannot call any non-static member, trying to do so will also result in an error...

Tuesday, June 22, 2004

VJs Tip Of The Day - June 22nd 2004

@Page directive

@Page directive of ASP.Net Page in visual studio accepts only fully qualified name for "Inherits" attribute whereas giving just the required cs file name for "Codebehind" attribute is good enough...

eg < %@ Page language="c#" Codebehind="UnExpectedError.aspx.cs" AutoEventWireup="false" Inherits="SubtleEye.Administration.UnExpectedError" % >

Monday, June 21, 2004

VJs Tip Of The Day - June 21st 2004

Redirecting to Default Error Html in case of Error

You might have many errors handled in your application but still there would be few of them always left out, so what's the solution??... Well here it is... Go and do the setting in the web.config file of your web application...
< customErrors defaultRedirect="UrProblemUnknownError.htm" mode="RemoteOnly" >
< error statusCode="404" redirect = "MyProblemServerNotFound.htm"/>
< /customErrors >

Now interesting fact is in conjunction to our previous tip on "SmartNavigation"... In case of pages for which you allow SmartNavigation the defaultRedirect does not work and Microsoft has confirmed it to be a bug... At the same time there is a work around...
Change your page directive a little bit when you use "SmartNavigation" as follows

< %@Page Language="C#" smartNavigation="True" ErrorPage="UrProblemUnknownError.htm" %>

The ErrorPage here will help you in that scenario... Don't ask me why so, You should not ask embarrassing questions... :-)

PS: I celebrate Mother's day today as it's my mom's birthday today... Happy Mother's Day!!

Thursday, June 17, 2004

VJs Tip Of The Day - June 17th 2004

Smart Navigation

"SmartNavigation" is a boolean property which can be set in the page's code behind or in the @page directive... This property is really helpful in case you want to enhance user experience... Set this property to true and you will get following advantages in navigation if your browser is IE 5.5 and above...
1.) Maintaining the scroll bar position (useful in long length pages)
2.) Set focus to the same control on which it was before navigation (useful in pages with lots of controls)
3.) saving last page state in the browser history (useful when a page does not changes considerably across frequent postbacks... eg chaning control values on change of dates in calendar control)
4.) The flash effect caused during navigation (useful when your page is pretty heavy to load)

Wednesday, June 16, 2004

VJs Tip Of The Day - June 16th 2004

Our Simple Response.Redirect method

Whenever Response.Redirect line is executed the browser gets a HTTP staus code of 302 from the server indicating it to GET/POST again to the new URL provided... This means that the page does one more round trip to the server with different URL... Most of the browser use GET request to comply with HTTP standards and if they use POST then they would have to prompt the user for permission... In anycase there is a performance hit of posting twice... Most of the cases it is not visible to the user...

If you are very high on performance then use Server.Transfer instead... Also note that your form variables are not available in the next page in case of Response.Redirect; in case of Server.Transfer the data submitted by the user is preserved...

Well I think this is long enough for a tip, so rest of the info I will include in a small article...

Tuesday, June 15, 2004

VJs Tip Of The Day - June 15th 2004

AlternateText Property

"AlternateText" property in the Image control is for narrator to read when a disabled person is trying to access the page via Narrator... Remember this when you are trying to develop an application for disabled people as well...