Najam Sikander Awan
logs of my work and digital life
logs of my work and digital life
Jun 24th
Today from a blog I discovered this project called ELMAH: Error Logging Modules and Handlers by the name you can guessed by now what it does
and let me tell you it does it very well. After reading a tutorial ELMAH plugged into my asp.net 3.5 test project and working good. I really liked it and thinking to use it into my future projects.
If you need a serious error logging utiliy download ELMAH now.
Jun 24th
If ELMAH project will not work for me I will implement this error handling technique from scott gu blog.
Jun 22nd
These parts are taken from msdn and some might be taken from other websites.
An interface can inherit from one or more base interfaces.
When a base type list contains a base class and interfaces, the base class must come first in the list.
A class that implements an interface can explicitly implement members of that interface. An explicitly implemented member cannot be accessed through a class instance, but only through an instance of the interface.
Ref: http://msdn.microsoft.com/en-us/library/87d83y5b(VS.80).aspx
Interfaces can consist of methods, properties, events, indexers, or any combination of those four member types. An interface cannot contain fields. Interfaces members are automatically public.
if a base class implements an interface, the derived class inherits that implementation.
Classes and structs can inherit from interfaces in a manner similar to how classes can inherit a base class or struct, with two exceptions:
To implement an interface member, the corresponding member on the class must be public, non-static, and have the same name and signature as the interface member. Properties and indexers on a class can define extra accessors for a property or indexer defined on an interface. For example, an interface may declare a property with a get accessor, but the class implementing the interface can declare the same property with both a get and set accessor. However, if the property or indexer uses explicit implementation, the accessors must match.
Interfaces can inherit other interfaces. It is possible for a class to inherit an interface multiple times, through base classes or interfaces it inherits. In this case, the class can only implement the interface one time, if it is declared as part of the new class. If the inherited interface is not declared as part of the new class, its implementation is provided by the base class that declared it. It is possible for a base class to implement interface members using virtual members; in that case, the class inheriting the interface can change the interface behavior by overriding the virtual members. For more information about virtual members
Overview:
An interface has the following properties:
Jun 9th
hi
I have been reading these guides for a while to learn git I thought i should share them with rest of the gang.
http://www.sourcemage.org/Git_Guide
http://www.kernel.org/pub/software/scm/git/docs/everyday.html
Jun 8th
Hello guys,
This is my first Bll class that is using linq and returning objects to presentation layer. Main data component class is ItemsDT which contain another skeleton class “ItemGridView” for custom view of items data table. “ItemGridView” contains basically have the fields that i want to show in my presentation layer. Note that items datatable has many column which can be reterived by calling AllItems() method.
If you just want to list all the methods into your table that is also included into your linq to sql file then you can set your method return type to list collection of the type that specified in dbml file (linq to sql). For example if you add items table into your linq to sql you will have a new type or class called Item. From your linq code you can return all the rows into the table as objects. Now these objects you can have as list collection of type Items so your method can return List<Items> and this return list will bind to any databound control like grid view with ease.
Problem arises if someone say only show selective columns then if you try to select few colums you will see visual studio provding you hint that objects return from the linq query will be of annonymous type. So to tackle this you have two options either spicy your return varriable of object type or write a skelton class that have all those columns you want to have from your datable. Below is the code with skelton class approch its easy to guess skelton class will define a type and visual studio will not alert anymore by saying your objects are of annonymous type.
public class ItemGridView
{
public int itemID { get; set; }
public string itemName { get; set; }
public string itemgroupName { get; set; }
}
[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select)]
public static List<ItemGridView> ListSubGroups_Admin()
{
return (from t in AllItems() select new ItemGridView {
itemID = t.sgID,
itemName = t.sgName,
itemgroupName = t.Group.gName
}).ToList<ItemGridView>();
}
Jun 8th
hi folks
After developing few asp.net 2.0 websites as our hosting upgraded to asp.net 3.5 I am finally making a dynamic website in asp.net 3.5 using linq to sql and I am trying hard to follow 3 tier model.
I will keep posting about this learning adventure of mine.
Jun 2nd
Hi Folks,
Today I have experimented with visual studio 2008 code themes and now I am having beautiful code themes with dark background.

To download vs 2008 themes please visit http://winterdom.com/?s=color+schemes
Feb 3rd
hi guys,
Well I like to share one more experiment with you that is how to call a webservice from your javascript(jquery). For that again you need to have an asp.net ajax enable website.
Lets first examine what are the requiments for webservice if we need to call it from javascript well after having asp.net ajax enable website first is you should mark your serverice as [ScriptService] what it does it will make all the methods/functions of your webservice to be accessable from javascript code and it also serialise your webservice response using JASON .
By default asp.net web services use soap for communication scriptservice marker make your webservice to use JASON.
Now lets defien the method in our webservice which we want to be accessable by our javascript code.
That’s it now lets move to client side code.
type: "POST",
url: "WebServices/MyWS.asmx/AddingNumbers",
data: "{‘a’:’1′,’b':’2′}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Do something interesting here.
alert(msg);
},
error: function()
{
alert("Request can’t made using ajax");
}
});//ajax ends here
});// document ready ends here
In above javasrcipt code we are making an ajax post request we set contentType to “application/json; charset=utf-8″ and dataType to “json” and passing a=1,b=2 as are data input parameters note that varriables name are same as verriables declared in webservice’s function AddingNumbers input parameters.
Please read articles from following links to know more and have a strong background.
http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/
http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/
http://www.keithrousseau.com/blog/2008/05/using-jquery-json-with-aspnet/
Feb 3rd
Hi guys,
Today I have installed a new wordpress plugin called “Code Snippet” and it support code highlight for many languages try this out you would love it. Download it now.
Feb 3rd
Hi guyz,
Today I am sharing how to call asp.net web page code behind methods from client side javascript in my case it will be jquery.
Let us divide this into two parts the server side and client side on server side we have to write a function or page method.
Note that we mark our AddStrings function as WebMethod and its public and static this is the basic requirement for the funtion if you want to call it from javascript or jquery.
Function itlsef is pretty simple all it does takes two strings join them and return the result. Thats all we need to write for server side.
type: "POST",
url: "Default.aspx/AddStrings",
data: "{a:’najam ‘,b:’sikander’}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Do something interesting here.
alert(msg);
},
error: function()
{
alert("Request can’t made using ajax");
}
});//ajax ends here
});// document ready ends here
Client side has its own requirements first its better to use post request if you want any result back from server and then you should use json as communication medium and for that we need to set content type and data type as
contentType: “application/json; charset=utf-8″, dataType: “json” and we should supply the input data with our request. Please note that if your server side function expecting two parameters named “a” and “b” you should name your javascript input parameters same as server side parameters thats why in data section we have same name of the varriables. Example data: “{a:’najam ‘,b:’sikander’}”,
Last requirement is your web.config should have entries for asp.net ajax sections. If you are building from scrath you can shoose asp.net ajax website as template when starting new website.
Please read articles from following links to know more and have a strong background.
http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/
http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/
http://www.keithrousseau.com/blog/2008/05/using-jquery-json-with-aspnet/