Archives

Archives / 2008 / March
  • Many new Admin modules for IIS7

    Hi

    Its been a few days that I have not been able to post blogs. I have been very busy these while. But yesterday I found this blog which talks about lot of cool new admin modules for IIS7.  The blog also explains how to use the modules. Do check it.

    Vikram

  • How to know the all the data in the cache of an Asp.Net Application

    Hi,

     

    We all know about the use of caching in our application. With good use of cache we can increase the performance of the application considerably since application does not have to process the stuff again and again. But if we use too much of caching in the application, it can be problem. After all the data in the cache has to be stored in the memory and most of the application have limited memory. And more so in case of shared hosting.

     

    But how do you know how much amount of cache is being cached. This need to be calculated at the runtime to know the data in the cache. This can help individual understand the requirement of application and change the hardware (if required). You can also remove some caching, if you cannot increase the hardware.

     

    To find all the data in the cache based on the Key we can use the following code.

     

    foreach (DictionaryEntry de in this.Cache)

    {

            Response.Write(de.Key);

            Response.Write(" : ");

            Response.Write(de.Value);

            Response.Write("<br><br>");       

    }

     

    You can also bind the data to a Gridview with two bound column for key and value. This will shows us the amount of data in the cache for individual key. This can be super handy when you application is making big use of caching data.

     

    Vikram

  • Working with cookies and JavaScript

    Hi,

     

    I have discussed about cookies in my previous posts. But in all those posts I talked about working with cookies in server side.

    You can read these posts here

       

    In this post I will talk about working with cookies in the client side.

     

    Many a times we want to work with cookies in the client side itself. We can use JavaScript to create, read and delete cookies. This can increase the productive way to work with cookie. We can access the cookies in the JavaScript with the help of the property document.cookie

     

    To create a new cookie we can use the following line of code.


    document.cookie = vikcookie1=VikFirstCookie; expires=Thu, 2 Aug 2001 20:47:11 UTC; path=/


    Here first we provide the Name value pair, then the expire date in give format (being separated with ; and space) and then the path (again separated with ; and space). You can set many cookies like this by just changing the Name of the key in the cookie.

     

    You can read a cookie with document.cookie. But this time the value returned will only be the name value pair. If there are more number of cookies for the domain then we will get multiple name value pair separated with semicolon and space. So the value returned by document.cookie will be something like

     

    vikcookie1=VikFirstCookie; vikcookie2=VikSecondCookie

     

    We can reset a cookie by overriding the cookie with the same name and different value or Expiry date.

     

    To remove a cookie all we have to do is to modify a cookie with the expiry date set to date before today. When the browser finds that the cookie has expired it will be automatically remove the cookie.

     

    Vikram

  • Microsft releases SilverLight 2.0 Beta 1, Asp.net MVC preview and IE8 Beta1

    Hi,

     

    Seems like Microsoft has decided to go for many releases on a day on the first day of MIX. Yes today Microsoft not only announced the release of IE8 Beta1 but also the preview of the Asp.Net MVC and Silverlight 2.0 Beta 1. This is way too much to work on at the same time. But who is complaining. :-)

     

    I am specially excited about many of the controls available in the Silverlight 2.0

     

    And yes I forget to say about the Asp.Net 3.5 extension preview 2

     

    Vikram

  • Microsoft launches IE8 beta 1 in public

    Hi,

     

    The beat 1 of the most dominated web browser’s next version is out for grab and it comes with many features too. The IE8 Readiness Toolkit which will give a detailed description of the features. You can download the same here.

     

    Some of the new features are

     
    • Activities
    • WebSlice
    • cascading style sheets 2.1 compliant
    • Developer Tools
     

    Vikram

  • Binding keyboard shortcut in Asp.Net

    Hi,

     

    Many a times when working with the Web Application you would like to give the user the comfort of getting the job done without using the mouse. It can be of great use to the user if they can perform many tasks using the keyboard in a web application. If you have used Gmail you would know how easy it can be to select mails using some key.  This feature can be implemented in Asp.net also very easily.

     

    In my example I will talk about how to link a key button with the click event of a button. What we will do is bind the keyboard shortcut to the click event of a button, hence the task will be performed on both keyboard click and mouse click of the button.

     

    document.attachEvent('onkeyup', KeysShortcut);

     

    // Now we need to implement the KeysShortcut
    function KeysShortcut ()

    {

         if (event.keyCode == 49)

         {  
           document.getElementById('<%= button1.ClientID %>').click();

         }

    }

     

    Now when the user click on the key 1 the click event of the button1 will be fired.

     

    Vikram