Najam Sikander Awan

logs of my work and digital life

Follow me on TwitterRSS Feeds

  • Home
  • About Me

ELMAH: Error Logging Modules and Handlers

Jun 24th

Posted by Najam Sikander Awan in Asp.net

No comments

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 :P 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.

.net, asp.net, web development

Show Detailed ASP.NET Error Messages to Developers

Jun 24th

Posted by Najam Sikander Awan in ToDo

No comments

If ELMAH project will not work for me I will implement this error handling technique from scott gu blog.

Read the post now.

asp.net

C# Interfaces

Jun 22nd

Posted by Najam Sikander Awan in Concepts

No comments

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:

  • A class or struct can inherit more than one interface.
  • When a class or struct inherits an interface, it inherits only the method names and signatures, because the interface itself contains no implementations

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:

  • An interface is like an abstract base class: any non-abstract type inheriting the interface must implement all its members.
  • An interface cannot be instantiated directly.
  • Interfaces can contain events, indexers, methods and properties.
  • Interfaces contain no implementation of methods.
  • Classes and structs can inherit from more than one interface.
  • An interface can itself inherit from multiple interfaces.

Ref: http://msdn.microsoft.com/en-us/library/ms173156.aspx

C#, Concepts, OOPS

Git version control Guides

Jun 9th

Posted by Najam Sikander Awan in Uncategorized

No comments

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

http://spheredev.org/wiki/Git_for_the_lazy

git

BLL – Business layer with Linq

Jun 8th

Posted by Najam Sikander Awan in Asp.net

No comments

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 ItemsDT
{
[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select)]
public static List&lt;Items&gt; AllItems()
{
DBDataContext db = new DBDataContext();
return (from t in db.Items select t).ToList&lt;Items&gt;();
}

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&lt;ItemGridView&gt; ListSubGroups_Admin()
{

return (from t in AllItems() select new ItemGridView {
itemID = t.sgID,
itemName = t.sgName,
itemgroupName = t.Group.gName
}).ToList&lt;ItemGridView&gt;();
}

asp.net, web development

Finally I have my hands on linq

Jun 8th

Posted by Najam Sikander Awan in Uncategorized

No comments

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.

linq
colorcode

dark code theme for vs 2008

Jun 2nd

Posted by Najam Sikander Awan in Tips & Tricks

No comments

Hi Folks,

Today I have experimented with visual studio 2008 code themes and now I am having beautiful code themes with dark background.

colorcode

To download vs 2008 themes please visit http://winterdom.com/?s=color+schemes

Tips, Visual Studio

Consuming asp.net webservice with jquery

Feb 3rd

Posted by Najam Sikander Awan in Ajax

No comments

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.

[WebMethod]
public int AddingNumbers(int a, int b)
{
return a + b;
}

That’s it now lets move to client side code.

$(function(){
$.ajax({

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/

Ajax, asp.net, Jquery, web services

Highlight your code with wordpress

Feb 3rd

Posted by Najam Sikander Awan in Uncategorized

No comments

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.

Tips, Wordpress

Calling asp.net page methods with jquery

Feb 3rd

Posted by Najam Sikander Awan in Ajax

No comments

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.

[WebMethod]
public static string AddStrings(string a, string b)
{
return string.Format("my friend answer is {0}", a + b);
}

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.

$(function(){
$.ajax({

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/

Ajax, asp.net, Jquery, web services
«12345»...Last »
  • My latest tweets

    Loading tweets...
    Follow me on Twitter!
    • Recent comments
    • Popular posts
    • Archives
    • Tags
    • Categories
    • Ajax (2)
    • Articles (1)
    • Asp.net (11)
    • C# (9)
    • Concepts (5)
    • Counter Strike (1)
    • Designing (2)
    • Devlopment (10)
    • Firefox (7)
    • git (2)
    • I Want To Know? (3)
    • Javascript (3)
    • Jquery (4)
    • linq (2)
    • Linux (8)
    • My Stuff (1)
    • Photoshop (1)
    • Projects (3)
    • Sql (1)
    • Telecommunication (2)
    • Tips & Tricks (7)
    • Today (33)
    • ToDo (1)
    • Troubles (1)
    • Uncategorized (38)
    • Wordpress (3)
    .net acer Ajax announcements asp.net audio driver boot loader Browsers Browsing C# chrome Concepts Counter Strike Data Access Database development dual boot fedora Firefox game git grub Javascript Jquery linq Linux mac spoofing multimedia News OOP OOPS Project realtek sound card Sql suse Tips Visual Studio vychat web development web services wifi Windows windows xp Wordpress
    • July 2010 (2)
    • January 2010 (1)
    • July 2009 (6)
    • June 2009 (8)
    • February 2009 (3)
    • January 2009 (4)
    • September 2008 (1)
    • July 2008 (6)
    • November 2007 (2)
    • October 2007 (1)
    • September 2007 (2)
    • June 2007 (2)
    • April 2007 (3)
    • March 2007 (3)
    • February 2007 (4)
    • January 2007 (1)
    • December 2006 (3)
    • April 2006 (2)
    • February 2006 (3)
    • January 2006 (2)
    • December 2005 (5)
    • November 2005 (4)
    • Gmail, Msn Live and other invites (27)
    • My Acer Aspire 1642ZNWLCi (15)
    • Real Firefox (7)
    • Msn Messenger Live (6)
    • Vychat alternative for my suse 10.2 laptop (5)
    • Fedora Core6 live-configuring internet by spoofing mac address (4)
    • Who invented CDMA (3)
    • oh God Hd audio driver for linux (3)
    • Read SMTP settings from asp.net web.config (3)
    • Realtek HD sound card working (2)
    • Kaifi: Yest it is :). Great Work Najam....
    • Najam Sikander Awan: @Anthony hi thanks for reading my blog and thanks for commenting and posting solution to our common...
    • Anthony Alexander: If you haven't already solved the problem, I just found the solution myself. open Apache...
    • faheem: http://www.cplug.org/guides/post-install.html
    • admin: thanks dear :)
    • Muhammed Shakhsheer: Hi Najam i have Acer aspire 1642ZNWLCi, which is the same you do, i have a problem that i dont...
    • John chaffee: Oh Man...thank you so much for posting! I have been working non this for about 4 hours. I...
    • Imran Agha: Hi Najam/Everyone, I have a Acer 1642 Laptop. Unfortunately its motherboard has gone bust and I...
  • User Login






    • Lost your password?
    • My latest tweets

      Loading tweets...
      Follow me on Twitter!
Mystique theme by digitalnature | Powered by WordPress
RSS Feeds XHTML 1.1 Top