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.
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(" : ");
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.
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
- Asp.net cookies an overview
- Asp.net Reading and writing value in cookies
- Subkeys scope limitation of a cookie in Asp.Net
In this post I will talk about working with cookies in the client side.
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
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.
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. :-)
And yes I forget to say about the Asp.Net 3.5 extension preview 2
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
- cascading style sheets 2.1 compliant
- Developer Tools
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.
// 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.