ReadOnly TextBox causes page back when enter backspace key

As Mention in the title of this post, the browser behavior always think that user want to go back(to previous page) when back space key in entered. So for the read only text box, the edit mode for the text box is not enable hence the backspace key will cause page to go back to previous page. The solution is to put the JavaScript at the Read Only Text Box to prevent page from go back to previous page. The Script  function preventBackspace(e) {              var evt = e || window.event;              if (evt) {                  var keyCode = evt.charCode || evt.keyCode;                  if (keyCode === 8) {                      if (evt.preventDefault) {                          evt.preventDefault();                      } else {                          evt.returnValue = false;                          alert("This is a read only field");                      }                 }                  else {                      evt.returnValue = false;                      alert("

Change Default Browser for MVC

Do you ever have problem to change default browser for Asp.Net MVC application? Here simple solution to change default browser for mvc application. Follow this step : Right click at solution explorer on mvc application and choose add new item. Choose "Web Form" file. Right click at web form file and choose browse with to change default browser for your mvc application. By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Get query string value JavaScript

Query string is a one solution to pass the value from one page to another without use session. It is just keys and value pass through url. Suppose the web application want to get the query string value at client side for the validation on the client side. So i use JavaScript to solve this. Here my JavaScript function to return query string...just pass the key for the query string in the function parameter and you will get the value of query string... Lets take a look at the example : The Javascript        function querystring(key) {             var re = new RegExp('(?:\\?|&)' + key + '=(.*?)(?=&|$)', 'gi');             var r = [], m;             while ((m = re.exec( != null) r.push(m[1]);             var stringQuery = r[0];                  return stringQuery;         } Example  <html xmlns=""> <head runat="server">     <title></title>     <script type=&q

Count number of tables in a SQL Server database

I got a request from a user and he wanted to count the number of tables in a database. It's quiet simple. Just use the information_schema.tables USE <db name> SELECT COUNT(*) from information_schema.tables WHERE table_type = 'base table' Will return you the count of the tables in the database The Tables The sql statement  USE SQLMembershipOptima SELECT COUNT(*) from information_schema.tables WHERE table_type = 'base table' The Output By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Message Box in ASP.NET CSS,CustomValidator,Validation Summary and Example

Message is a must in a web application. Message can be used to show information,warning,error, and successfully message to tell users the status of their process. This is a sample message that can be use in your web application. Have a try. First of all, you can download all this image icon and add to your web application project. The CSS File   .notification         {             position: relative;             margin: 0 auto;             padding: 2px 10px 2px 2px;             border: 1px solid;             background-position: 10px 11px !important;             background-repeat: no-repeat !important;             font-size: 12px;             width: 99%;         }                 .attention         {             background: #fffbcc url('../Images/Icon/exclamation.png') 10px 11px no-repeat;             border-color: #e6db55;             color: #666452;         }                 .information         {             background: #dbe3ff url('../Images/Icon/information.png&#

Image Resizer Class Example

Images often represent a significant fraction of both the data required by the browser to render a page fully and a site’s bandwidth use. For those reasons, it’s important to make sure that you don’t send large images to the client when smaller ones will work just as well. If your images are too big or have a much higher quality than your users need, you might of course choose to resize or recompress them statically. An alternative is to resize and recompress your images dynamically and cache the results as you go. You might create a user control to do that, for example, or for a large library of images, you might do it in a background thread. Since the number and size of the images could be large and since IIS has an efficient method for caching static files, you should generally store the resized images as files rather than in memory. Here is a example of class Image Resizer in C# The ImageResizer Class using System; using System.Drawing; using System.Drawing.Imaging; using System.Dr

Clear all cache in ASP.NET

The previous post was about advantage using cache in web application .Complex application must using cache to increase the performance of application. But sometime you a over heating the memory if so many information stored in cache and the cleaner(GC) need to clean up the mess. Unfortunately Garbage Collector(GC) not remove the cache, you need to do it by your self. The problem is how to get all key of the cache and then remove it.? So the solution is you need to use the IDictionaryEnumerator to get all of the cache key. Lets look at the method example. Feel free to try by your self. Clear Cache Method  public void clearCache()         {             IDictionaryEnumerator dictionaryEnumerators = Cache.GetEnumerator();             if (dictionaryEnumerators.MoveNext())             {                 Cache.Remove(dictionaryEnumerators.Key.ToString());                 clearCache();             }                     } By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will app