March 03, 2009

ADO.NET Entity Framework and Linq Framework

0 comments

I googled for this and i have found the following links which will clear many confusions 

  • http://msdn.microsoft.com/en-us/library/cc161164.aspx
  • http://dotnetaddict.dotnetdevelopersjournal.com/adoef_vs_linqsql.htm
  • http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/55a7a796-2bef-4df9-b858-2f9804d39af5/
  • http://dotnethitman.spaces.live.com/blog/cns!E149A8B1E1C25B14!195.entry
  • Please go thru these links once.

    February 19, 2009

    Writing Your Own HttpHandler

    0 comments

    Hi All,

    Today i'll explain how to write our own handler for a new kind of page. Firstly, Handlers(as the term explain) are for handling things. These things are client requests. So for a client request to Default.aspx there will be a handler. This will be a default handler which will ship along with asp.net runtime. If you have new kind of extension you can writer your own handler.
    The reason of writing this blog is for a good understanding of http handlers. I insist you to follow these steps and create your own handler. I have followed these procedures from the site:

    http://www.15seconds.com/Issue/020417.htm

    Step 1:
    In u r VS, create a new c# class library and the name the class as MyOwnHandler.
    The code should be

    using System;
    using System.Web;
    using System.Text;
    namespace MyCustomizedHandler
    {
      public class MyOwnHandler: IHttpHandler
      {
         public MyOwnHandler()
         {
         }
          #region for implementing HttpHandler
          Public void ProcessRequest(HttpContext context)
          {
             HttpResponse responseObject = context.Response;
             responseObject.Write("<html><body><h1>My Customized page</h1>");        
     responseObject.Write("</body><html>");
           }
           Public bool IsReusable
           {
                get
                {
                      return true;
                }
           }
           #endregion
          }
      }
    }
    Rather than copying and pasting i insist all of u to type this small piece of code manually. Now just compile this from ur VS and paste the output of this dll into a virtual folder webapplication. I have a website in my iis with the name 'jsonSamples', so i placed the dll output of the above code into the bin directory of 'jsonSamples'. 

    Step2: 
    Now open the web.config file of the webapplication(in my case 'jsonSamples') and add the following piece of code inside it:
    <httpHandlers>
         <add verb="*" path=".sample" type="MyCustomizedHandler.MyOwnHandler,       MyCustomizedHandler">
    </httpHandlers>

    Step3:
    All what we have done is in the application level. i.e., our application knows how to render a request for the page type .sample. Now we have to tell this to the iis webserver also. For that we have to do:
    Launch IIS, right click on Default Web Site, go to home directories tab, click on configuration. This will open a new window. Now click on the add button and in the Executable section give the url of the aspnet_isapi.dll. Down to it, the extension should be given as 'sample'.
    Click all ok's and close the window.

    Now from ur browser just make a request some thing like this:
    http://localhost/jsonSamples/helllo.sample
    http://locahost/jsonSamples/239kshrkweh.sample
    http://localhost/jsonSamples/anything.sample

    You should get the output. (But i didn't get the output for the first time)
    If u dont get the output then dont panic, just open ur webapplication(jsonSamples) in VS and for it add reference of u r class library dll. Even though u have placed the dll in the bin directory of the webappliation but u need to do add reference to the same item once again from VS. I dont know why but it works.

    Hope this helped.

    February 16, 2009

    Improve u r english

    0 comments

    Hi Friends,

    I have found a site that help u improving u r english skills. It was really helpful for me. May be u should also  take a look at it.
     
    http://www.pandorabots.com/pandora/talk?botid=f5d922d97e345aa1

    February 13, 2009

    List all Running Applications through windows script

    0 comments

    Hi All,

    The following is a simple script which will list all the applications inside ur taskmanager applications tab.

    Set objWord = CreateObject("Word.Application")
    Set colTasks = objWord.Tasks

    For Each objTask in colTasks
        If objTask.Visible Then
            Wscript.Echo objTask.Name
        End If
    Next

    objWord.Quit

    Must and should read link:

    Infact i actually copied the above code from this link only. This was really very helpful and it explained me a lot. I'd simply like to say: "All the processes which are not running in hidden mode are listed in the applications tab.If a process doesn't have a visible window then it will not be present in the applications tab."

    I really insist all of u to go through the above link for a better understanding of things.
    Hpy Scripting.........

    February 09, 2009

    Open Yahoo Mail through Windows Script

    0 comments

    Hi People,

    I'm a Newbie to scripting world. I thought of writing a windows script which will take my credentials and automatically logs me into yahoo. With lots of googling i  m able to write the following code:

    set objIE = CreateObject("InternetExplorer.Application")
    objIE.Navigate "www.mail.yahoo.com"
    objIe.Visible = true

    'wait untill page gets loaded
    While objIE.busy
    WScript.Sleep 1000
    Wend

    objIE.document.getElementByID("username").value = "my_username"
    objIE.document.getElementByID("passwd").value = "my_password"
     objIE.document.getElementsByName(".save")(0).click()

    That's it. Copy and paste the above code. Yeah pls fill corresponding username and password fields. This code needs to be worked in the following sections:

    1)Inside the if condition i m finding the username textbox through DOM selection and then filling in the appropriate fields. But this may affect if the textbox name changes.

    The following are some of the links where u can find some more useful information:






    January 28, 2009

    CSS Tips

    0 comments

    The disadvantage of using table-layout is, once the entire table is loaded then only u can view it. This is a performance issue interms of user experience, for ex if u have table with hundred images, until all the images r loaded u cannot see them. Instead if u follow some other way like using div's, it might be good.


    Also dont overwrite styles until unless they r explicitly required. This is because if u have color coming for a p element from two style rules then it is considered as an error in css validator checks.

    Giving negative margins will mess up things in IE6.


    December 22, 2008

    Nullable Types in C#

    0 comments

    int x = 0; //valid statement
    int y = null; //compile time error

    This is because we know that null is a value for reference types and since int is a value type it cannot hold the value null in it. So if there comes a situation where u need to hold null value inside an int then the solution is the Nullable Type.

    Any Value Type can be Nullable Type, which means that the default value can hold the possible value in its data range as well as a new value 'null' in it. The syntax for this is,

    int? x = null; //valid statement; now x is a nullable type

    Also dont guess that since now x can hold null value, it can be reference type. This is wrong. What Nullable Type is like a wrapper around a value type which can hold a null value also. So the value of x is stored in stack(by default).