Posts

Get query string value JavaScript

Image
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(document.location.search)) != null) r.push(m[1]);             var stringQuery = r[0];                  return stringQuery;         } Example  <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title>     <script type=&q

Count number of tables in a SQL Server database

Image
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

Image
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

Improve load page performance by setting Browser Cache for Static Content - ASP.NET

Image
Files that the browser retrieves from the server should be stored in the browser’s cache as long as possible to help minimize server round-trips. If a page and all the resources it requires are in the browser’s cache, no server round-trips at all are required; the browser can render the page using only the cached content. Since that presents no load on the network or the server, it is obviously very good for scalability. Caching Static Content Every object stored in the browser cache includes an expiration time, beyond which the browser considers the content stale or invalid. You can manage those expiration times with the Cache-Control: max-age HTTP header. The Expires header performed the same function with HTTP 1.0, but Cache-Control overrides Expires when both are present. I prefer to use only Cache-Control when possible, thereby avoiding the confusion that might arise when you have two headers that specify the same thing. If you set neither the Expires nor Cache-Control: max-age HT

Caching in ASP.NET advantage and example

Caching in ASP.NET Today i want to discuss, how to improve web performance in asp.net. One of the approach are using Caching in asp.net application. The caching is a must in a Web application right now. This is because the caching will fasten access data directly from memory(RAM) rather than access in Hard Disk. This are advantage of using Caching in Web Application Advantage : Reduce round-trips: Content cached at the client or in proxies can eliminate web server round-trips. Content cached at the web server can eliminate database round-trips. Move content closer to clients: The farther away from clients content is located, the longer it takes to retrieve that content. Avoid time-consuming processes of regenerating reusable content: For content that takes a lot of time or resources to generate, system performance and scalability are improved if you can generate content once and then reuse it many times. Optimize state management: Caching state information at the client is more scalabl