<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-14777607361869275</atom:id><lastBuildDate>Fri, 06 Sep 2024 04:59:33 +0000</lastBuildDate><category>jQuery</category><category>C#</category><category>ASP.NET</category><category>Javascript</category><category>T-SQL</category><category>Blogger Tips and Tricks</category><category>Css</category><category>Css3</category><category>Life Story</category><category>Music</category><category>Plugin jQuery</category><category>Tech Videos</category><category>Tips_And_Tricks</category><title>Code For Fun</title><description>Sharing the Knowledge about programming with jQuery, Java, ASP.NET, PHP, C# ......</description><link>http://cool-develop.blogspot.com/</link><managingEditor>noreply@blogger.com (Kelvin)</managingEditor><generator>Blogger</generator><openSearch:totalResults>43</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-7035913980784402356</guid><pubDate>Sun, 16 Sep 2012 12:12:00 +0000</pubDate><atom:updated>2012-09-16T19:20:57.739+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Tips_And_Tricks</category><title>Demo Code</title><description>&lt;pre class=&quot;csharpcode&quot;&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt; IsValidURL(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; strURL)
{
    &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; regExPattern = &lt;span class=&quot;str&quot;&gt;@&amp;quot;^^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\&#39;\/\\\+&amp;amp;%\$#_=]*)?$&amp;quot;&lt;/span&gt;;
    Regex re = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Regex(regExPattern);
    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; re.IsMatch(strURL);
}&lt;/pre&gt;
demo highlight &lt;code&gt;foo&lt;/code&gt; &lt;code&gt;bar&lt;/code&gt; 

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Demo Quote&lt;/p&gt;&lt;/blockquote&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/09/demo-code.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-5717351392670922418</guid><pubDate>Fri, 24 Aug 2012 17:49:00 +0000</pubDate><atom:updated>2012-08-26T15:47:14.143+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Blogger Tips and Tricks</category><title>Easy Change the Text Selection Color In Blogger</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;It very simple to change your select &lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;sentence or a single word prevent&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;by default with set as blue color. Now let&#39;s start:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;b&gt;1&lt;/b&gt;. &amp;nbsp;Go to&amp;nbsp;&lt;/span&gt;&lt;i style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;Blogger Dashboard&lt;/i&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;i style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;Template&lt;/i&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;i style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;Edit HTML.&lt;/i&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;b&gt;2&lt;/b&gt;. &amp;nbsp;Back up your template first if you don&#39;t want make some problem :)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;b&gt;3&lt;/b&gt;. &amp;nbsp;Check the&amp;nbsp;&lt;/span&gt;&lt;i style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;Expand Widget Templates&lt;/i&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;checkbox.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;b&gt;4&lt;/b&gt;. &amp;nbsp;Now search (&lt;/span&gt;&lt;i style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;CTRL+F&lt;/i&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;) for the code tag below:&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;tr_bq&quot;&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #222222; font-size: 13px; line-height: 18px;&quot;&gt;]]&amp;gt;&amp;lt;/b:skin&amp;gt;&lt;/span&gt;&lt;/pre&gt;And now &lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;add the below code before it&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;tr_bq&quot;&gt;&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;::-moz-selection{background: #9E0ADC;color: white;}&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;::selection{background: #9E0ADC;color: white;}&lt;/span&gt;&lt;/pre&gt;You can see demo on my blog.&amp;nbsp;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;Hope you enjoyed doing this trick for your blog.&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/08/easy-change-text-selection-color-in.html</link><author>noreply@blogger.com (Kelvin)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-4318376626641504693</guid><pubDate>Mon, 11 Jun 2012 03:23:00 +0000</pubDate><atom:updated>2012-06-11T10:28:58.039+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Javascript</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Regex quick reference</title><description>&lt;div id=&quot;quickref&quot;&gt; &lt;div style=&quot;float: left&quot;&gt; &lt;table style=&#39;width: 615px;&#39;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;[abc]&lt;/code&gt;&lt;/td&gt; &lt;td&gt;A single character of: a, b or c&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;[^abc]&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any single character except: a, b, or c&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;[a-z]&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any single character in the range a-z&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;[a-zA-Z]&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any single character in the range a-z or A-Z&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;^&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Start of line&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;$&lt;/code&gt;&lt;/td&gt; &lt;td&gt;End of line&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;\A&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Start of string&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;\z&lt;/code&gt;&lt;/td&gt; &lt;td&gt;End of string&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt; &lt;div style=&quot;float: left&quot;&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;.&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any single character&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;\s&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any whitespace character&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;\S&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any non-whitespace character&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;\d&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any digit&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;\D&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any non-digit&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;\w&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any word character (letter, number, underscore)&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;\W&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any non-word character&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;\b&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Any word boundary character&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt; &lt;div style=&quot;float: left&quot;&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;(...)&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Capture everything enclosed&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;(a|b)&lt;/code&gt;&lt;/td&gt; &lt;td&gt;a or b&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;a?&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Zero or one of a&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;a*&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Zero or more of a&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;a+&lt;/code&gt;&lt;/td&gt; &lt;td&gt;One or more of a&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;a{3}&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Exactly 3 of a&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;a{3,}&lt;/code&gt;&lt;/td&gt; &lt;td&gt;3 or more of a&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;code&gt;a{3,6}&lt;/code&gt;&lt;/td&gt; &lt;td&gt;Between 3 and 6 of a&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;  &lt;div style=&quot;text-align: left&quot; id=&quot;regex_options&quot;&gt; &lt;p&gt;options: &lt;code&gt;i&lt;/code&gt; case insensitive &lt;code&gt;m&lt;/code&gt; make dot match newlines &lt;code&gt;x&lt;/code&gt; ignore whitespace in regex &lt;code&gt;o&lt;/code&gt; perform #{...} substitutions only once &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/06/regex-quick-reference.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-8261338941748333346</guid><pubDate>Mon, 11 Jun 2012 03:07:00 +0000</pubDate><atom:updated>2012-06-11T10:18:43.472+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Remove Html Tag in C#</title><description>&lt;p&gt;You want to &lt;b&gt;remove HTML tags&lt;/b&gt; from your string. This is useful for displaying HTML in plain text and stripping formatting like bold and italics, while not removing any actual textual content. Test the methods available for this functionality for performance and correctness with test cases.  &lt;p&gt;These C# example programs show how to remove HTML tags from strings.&lt;pre&gt;&lt;b&gt;Removing HTML tags from strings&lt;/b&gt;

Input:    &amp;lt;p&amp;gt;The &amp;lt;b&amp;gt;dog&amp;lt;/b&amp;gt; is &amp;lt;i&amp;gt;cute&amp;lt;/i&amp;gt;.&amp;lt;/p&amp;gt;
Output:   The dog is cute.

&lt;b&gt;Performance test for HTML removal&lt;/b&gt;

HtmlRemoval.StripTagsRegex:         &lt;font style=&quot;background-color: #ffff00&quot;&gt;2404 ms&lt;/font&gt;
HtmlRemoval.StripTagsRegexCompiled: &lt;font style=&quot;background-color: #ffff00&quot;&gt;1366 ms&lt;/font&gt;
HtmlRemoval.StripTagsCharArray:      &lt;font style=&quot;background-color: #ffff00&quot;&gt;287 ms [fastest]&lt;/font&gt;

&lt;b&gt;File length test for HTML removal&lt;/b&gt;

File tested:                        Real-world HTML file
File length before:                 &lt;font style=&quot;background-color: #ffff00&quot;&gt;8085 chars&lt;/font&gt;
HtmlRemoval.StripTagsRegex:         &lt;font style=&quot;background-color: #ffff00&quot;&gt;4382 chars&lt;/font&gt;
HtmlRemoval.StripTagsRegexCompiled: &lt;font style=&quot;background-color: #ffff00&quot;&gt;4382 chars&lt;/font&gt;
HtmlRemoval.StripTagsCharArray:     &lt;font style=&quot;background-color: #ffff00&quot;&gt;4382 chars&lt;/font&gt;&lt;/pre&gt;
&lt;h4&gt;Examples&lt;/h4&gt;
&lt;p&gt;First, here is a static class that tests three different ways of removing HTML tags and their contents. The methods receive string arguments and then process the string and return new strings that do not have the HTML tags. The methods have different performance characteristics. As a reminder, HTML tags start with &lt;code&gt;&amp;lt;&lt;/code&gt; and end with &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;pre&gt;&lt;b&gt;HtmlRemoval static class [C#]&lt;/b&gt;

using System;
using System.Text.RegularExpressions;

&lt;i&gt;/// &amp;lt;summary&amp;gt;
/// Methods to remove HTML from strings.
/// &amp;lt;/summary&amp;gt;&lt;/i&gt;
public static class HtmlRemoval
{
    &lt;i&gt;/// &amp;lt;summary&amp;gt;
    /// Remove HTML from string with Regex.
    /// &amp;lt;/summary&amp;gt;&lt;/i&gt;
    public static string StripTagsRegex(string source)
    {
	return Regex.Replace(source, &quot;&amp;lt;.*?&amp;gt;&quot;, string.Empty);
    }

    &lt;i&gt;/// &amp;lt;summary&amp;gt;
    /// Compiled regular expression for performance.
    /// &amp;lt;/summary&amp;gt;&lt;/i&gt;
    static Regex _htmlRegex = new Regex(&quot;&amp;lt;.*?&amp;gt;&quot;, RegexOptions.Compiled);

    &lt;i&gt;/// &amp;lt;summary&amp;gt;
    /// Remove HTML from string with compiled Regex.
    /// &amp;lt;/summary&amp;gt;&lt;/i&gt;
    public static string StripTagsRegexCompiled(string source)
    {
	return _htmlRegex.Replace(source, string.Empty);
    }

    &lt;i&gt;/// &amp;lt;summary&amp;gt;
    /// Remove HTML tags from string using char array.
    /// &amp;lt;/summary&amp;gt;&lt;/i&gt;
    public static string StripTagsCharArray(string source)
    {
	char[] array = new char[source.Length];
	int arrayIndex = 0;
	bool inside = false;

	for (int i = 0; i &amp;lt; source.Length; i++)
	{
	    char let = source[i];
	    if (let == &#39;&amp;lt;&#39;)
	    {
		inside = true;
		continue;
	    }
	    if (let == &#39;&amp;gt;&#39;)
	    {
		inside = false;
		continue;
	    }
	    if (!inside)
	    {
		array[arrayIndex] = let;
		arrayIndex++;
	    }
	}
	return new string(array, 0, arrayIndex);
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Notes.&lt;/b&gt; This is a public static class written in the C# language that does not save state. You can call into the class using the code HtmlRemoval.StripTags*. Normally, you can put this class in a separate file named HtmlRemoval.cs. Because it is not project-specific, it is useful for many programs. 
&lt;p&gt;&lt;b&gt;StripTagsRegex.&lt;/b&gt; This method uses a static call to Regex.Replace, and therefore the expression is not compiled. For this reason, this method could be optimized by pulling the Regex out of the method, such as in the second method. The regular expression specifies that all sequences matching &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; with any number of characters, but the minimal number, are replaced with string.Empty (removed). 
&lt;p&gt;&lt;b&gt;StripTagsRegexCompiled.&lt;/b&gt; This method does the exact same thing as the previous method, but its regular expression is pulled out of the method call and stored in the static class. I recommend this method for most programs, as it is very simple to inspect and considerably faster than the first method. The static Regex will only be created once in your program. 
&lt;p&gt;&lt;b&gt;StripTagsCharArray.&lt;/b&gt; This method is a heavily optimized version of an approach that could instead use StringBuilder. In most benchmarks, this method is faster and is appropriate for when you need to strip lots of HTML files. A detailed description of the method&#39;s body is available below. 
&lt;h4&gt;Tests&lt;/h4&gt;
&lt;p&gt;Here we look at a program that runs these methods through a very simple test. The three methods work identically on valid HTML. One thing you should note is that the char array method will strip anything that follows &lt;code&gt;a &amp;lt;&lt;/code&gt;, but the Regex methods will require &lt;code&gt;a &amp;gt;&lt;/code&gt; before they strip the tag.&lt;pre&gt;&lt;b&gt;Program that tests HTML removal [C#]&lt;/b&gt;

using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main()
    {
	const string html = &quot;&amp;lt;p&amp;gt;There was a &amp;lt;b&amp;gt;.NET&amp;lt;/b&amp;gt; programmer &quot; +
	    &quot;and he stripped the &amp;lt;i&amp;gt;HTML&amp;lt;/i&amp;gt; tags.&amp;lt;/p&amp;gt;&quot;;

	Console.WriteLine(HtmlRemoval.StripTagsRegex(html));
	Console.WriteLine(HtmlRemoval.StripTagsRegexCompiled(html));
	Console.WriteLine(HtmlRemoval.StripTagsCharArray(html));
    }
}

&lt;b&gt;Output&lt;/b&gt;

There was a .NET programmer and he stripped the HTML tags.
There was a .NET programmer and he stripped the HTML tags.
There was a .NET programmer and he stripped the HTML tags.&lt;/pre&gt;
&lt;h4&gt;&amp;nbsp;&lt;/h4&gt;
&lt;p&gt;First, from my performance research I know regular expressions in the C# language are usually not the fastest way to process test. I wrote an algorithm that uses a combination of char arrays and the new string constructor to strip HTML tags, filling the requirement and often performing better. 
&lt;p&gt;The benchmark for these methods stripped 10000 HTML files of around 8000 characters in tight loops. The file was read in from File.ReadAllText. The result was that the char array method was considerably faster. This could worthwhile to use if you have to strip many files in a script, such as one that preprocesses a large website in memory. 
&lt;h4&gt;Iterative method&lt;/h4&gt;
&lt;p&gt;The method here that uses char arrays and is dramatically faster than the other two methods uses a neat algorithm for parsing the HTML quickly. It iterates through all characters, flipping a flag Boolean depending on whether it is inside a tag block. It only adds characters to the array buffer if it is not a tag. For performance, it uses char arrays and the new string constructor that accepts a char array and a range. This is faster than using StringBuilder. 
&lt;p&gt;Using RegexOptions.Compiled and a separate Regex results in better performance than using the Regex static method. RegexOptions.Compiled has some drawbacks, however. It can reduce startup time by 10x in some cases. More material is available pertaining to make Regexes simpler and faster to run. 
&lt;h4&gt;Self-closing tags&lt;/h4&gt;
&lt;p&gt;In XHTML, certain elements such as BR and IMG have no separate closing tag, and instead use the &lt;code&gt;&quot;/&amp;gt;&quot;&lt;/code&gt; at the end of the first tag. The test file noted includes these self-closing tags, and the methods handle it correctly. Here are some HTML tags supported.&lt;pre&gt;&lt;b&gt;Supported tags&lt;/b&gt;

&amp;lt;img src=&quot;&quot; /&amp;gt;
&amp;lt;img src=&quot;&quot;/&amp;gt;
&amp;lt;br /&amp;gt;
&amp;lt;br/&amp;gt;
&amp;lt; div &amp;gt;
&amp;lt;!-- --&amp;gt;&lt;/pre&gt;
&lt;p&gt;Source: dotnetperls.com &lt;/p&gt;
&lt;p&gt;See some example: &lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://cool-develop.blogspot.com/2012/06/remove-html-tag-with-jquery.html&quot; target=&quot;_blank&quot;&gt;How to remove Html Tag form Client site with jQuery&lt;/a&gt;&lt;/p&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/06/remove-html-tag-in-c.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-4812302517804648029</guid><pubDate>Mon, 11 Jun 2012 03:01:00 +0000</pubDate><atom:updated>2012-06-11T10:02:30.954+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Javascript</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Remove Html Tag with jQuery</title><description>&lt;p&gt;The example below show how to remove HTML tags from strings with jQuery&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;INPUT:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;code&gt;&amp;lt;b&amp;gt;&lt;/code&gt;We&lt;code&gt;&amp;lt;/b&amp;gt;&lt;/code&gt;love&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;jQuery.&lt;code&gt;&amp;lt;/span&amp;gt;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;OUTPUT:&amp;nbsp;&amp;nbsp; We love jQuery.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;jQuery source:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;var NewString = OriginalString.replace(/(&amp;lt;([^&amp;gt;]+)&amp;gt;)/ig, &quot;&quot;);&lt;/p&gt;&lt;/blockquote&gt;&lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-thumbsup&quot; alt=&quot;Thumbs up&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj__cA3dccKnb_8v0kx_Dhn5aC9JHp2GQuGTwUm5RZ-MkdGcuMVpJbkGYiBSo5MHXod0tyWshoBOmVcAeY_W1Lk5FGf-Lk07yx4sPr0I49VHIIcwixbUEe8IE8KccEqi8rQcPzF7Bp-TA/?imgmax=800&quot;&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/06/remove-html-tag-with-jquery.html</link><author>noreply@blogger.com (Johnson William)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj__cA3dccKnb_8v0kx_Dhn5aC9JHp2GQuGTwUm5RZ-MkdGcuMVpJbkGYiBSo5MHXod0tyWshoBOmVcAeY_W1Lk5FGf-Lk07yx4sPr0I49VHIIcwixbUEe8IE8KccEqi8rQcPzF7Bp-TA/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-6987442868381674751</guid><pubDate>Tue, 22 May 2012 11:51:00 +0000</pubDate><atom:updated>2012-05-22T19:10:19.125+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Tips writing jQuery function for beginner</title><description>&lt;p&gt;Wirting jQuery&lt;/p&gt; &lt;blockquote&gt; &lt;div class=&quot;csharpcode&quot;&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;&lt;span class=&quot;rem&quot;&gt;//----------------------------------------------&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;&lt;span class=&quot;rem&quot;&gt;//a shortcut code noConflict &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;($) {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;    &lt;span class=&quot;rem&quot;&gt;// do something on document ready&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;})(jQuery);&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;     &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;&lt;span class=&quot;rem&quot;&gt;//a long code&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;$(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;    &lt;span class=&quot;rem&quot;&gt;// put all your jQuery goodness in here.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;});&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;    &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;&lt;span class=&quot;rem&quot;&gt;//a shortcut code&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;$(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt;    &lt;span class=&quot;rem&quot;&gt;// do something on document ready&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  15:  &lt;/span&gt;});&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Fix error Conflict between many javascript library&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;//----------------------------------------------&lt;br&gt;//(noConflict) see reference site: &lt;a href=&quot;http://api.jquery.com/jQuery.noConflict/&quot;&gt;http://api.jquery.com/jQuery.noConflict/&lt;/a&gt;&lt;br&gt;//Many JavaScript libraries use $ as a function or variable name, &lt;br&gt;//just as jQuery does. In jQuery&#39;s case, $ is just an alias for jQuery, &lt;br&gt;//so all functionality is available without using $. &lt;br&gt;//If we need to use another JavaScript library alongside jQuery,&lt;br&gt;// we can return control of $ back to the other library with a call to $.noConflict():&lt;br&gt;&lt;code&gt;$.noConflict();&lt;/code&gt;&lt;br&gt;//or&lt;br&gt;&lt;code&gt;jQuery.noConflict();&lt;/code&gt;&lt;br&gt;// Code that uses other library&#39;s $ can follow here.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Multiple $(document).ready() in one javascript file&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class=&quot;csharpcode&quot;&gt;$(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {
    &lt;span class=&quot;rem&quot;&gt;// some code here&lt;/span&gt;
});
$(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {
    &lt;span class=&quot;rem&quot;&gt;// other code here&lt;/span&gt;
});&lt;/pre&gt;&lt;/blockquote&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Function define in one &lt;code&gt;$(document).ready&lt;/code&gt; block and call outside another &lt;code&gt;$(document).ready&lt;/code&gt; block&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; demoFunction;
$(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {
    &lt;span class=&quot;rem&quot;&gt;// some code here&lt;/span&gt;
    demoFunction = &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {
        &lt;span class=&quot;rem&quot;&gt;// some function that does stuff&lt;/span&gt;
    };
});

$(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {
    demoFunction();
});&lt;/pre&gt;&lt;/blockquote&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;continuous….&lt;/p&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/tips-writing-jquery-function-for.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-2413358787773223070</guid><pubDate>Sat, 19 May 2012 02:00:00 +0000</pubDate><atom:updated>2012-05-19T09:06:17.422+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Get URL after Rewrite in C#</title><description>&lt;p&gt;When you use the URL rewrite module in C# with mod_rewrite rules like&amp;nbsp; &lt;code&gt;www.domain.com/products/clothes&lt;/code&gt;&lt;/p&gt; &lt;p&gt;you can easy to get anything after &lt;a href=&quot;http://www.domain.com&quot;&gt;www.domain.com&lt;/a&gt; by use below code&lt;/p&gt; &lt;blockquote&gt; HttpContext context = HttpContext.Current; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt; = context.Request.RawUrl; &lt;/blockquote&gt; &lt;p&gt;and you can get it &lt;code&gt;/products/clothes&amp;nbsp; &lt;/code&gt;.Using function &lt;strong&gt;&lt;font color=&quot;#0000ff&quot;&gt;Regex&lt;/font&gt;&lt;/strong&gt; to Split that string &lt;/p&gt; &lt;blockquote&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;[] url = Regex.Split(&lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;, Regex.Escape(&lt;span class=&quot;str&quot;&gt;&quot;/&quot;&lt;/span&gt;)); &lt;/blockquote&gt; &lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/get-url-after-rewrite-in-c.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-827551633175323122</guid><pubDate>Thu, 17 May 2012 17:08:00 +0000</pubDate><atom:updated>2012-05-18T00:09:25.397+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><title>Sys.WebForms.PageRequestManagerParserErrorException</title><description>&lt;p&gt;When I try use Ajax ScriptManager to update panel, I have a trouble with an error : &lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;After just I Rebuild all project and no see last error but found another error:&lt;/p&gt; &lt;p&gt;&lt;code&gt;Uncaught Sys.ParameterCountException: Sys.ParameterCountException: Parameter count mismatch.&lt;/code&gt;&lt;/p&gt;   &lt;p&gt;now i don’t know how to fix it&lt;/p&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/syswebformspagerequestmanagerparsererro.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-6510711902439837370</guid><pubDate>Tue, 15 May 2012 06:31:00 +0000</pubDate><atom:updated>2012-05-15T13:31:06.776+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">T-SQL</category><title>Paging in SQL Server 2005 (ROW_NUMBER() - Select dữ liệu trả về trong 1 khoảng)</title><description>&lt;p&gt;Introduction &lt;p&gt;Developers and database administrators have long debated methods for paging recordset results from Microsoft SQL Server, trying to balance ease of use with performance. The simplest methods were less efficient because they retrieved entire datasets from SQL Server before eliminating records which were not to be included, while the best-performing methods handled all paging on the server with more complex scripting. The ROW_NUMBER() function introduced in SQL Server 2005 provides an efficient way to limit results relatively easily. &lt;p&gt;Paging Efficiency &lt;p&gt;In order to scale well, most applications only work with a portion of the available data at a given time. Web-based data maintenance applications are the most common example of this, and several data-bindable ASP.NET classes (such as GridView and Datagrid) have built-in support for paging results. While it is possible to handle paging within the web page code, this may require transferring all of the data from the database server to the web server every time the control is updated. To improve performance and efficiency, data which will not be used should be eliminated from processing as early as possible. &lt;p&gt;Paging Methods &lt;p&gt;Many popular databases offer functions allowing you to limit which rows are returned for a given query based upon their position within the record set. For example, MySQL provides the LIMIT qualifier, which takes two parameters. The first LIMIT parameter specifies which (zero-based) row number will be the first record returned, and the second parameter specifies the maximum number of records returned. The query:&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;table&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;LIMIT&lt;/span&gt; 20,13&lt;/pre&gt;
&lt;p&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;...will return the 20&lt;sup&gt;th&lt;/sup&gt; through the 32&lt;sup&gt;nd&lt;/sup&gt; records -- assuming at least 33 records are available to return. If fewer than 33 records are available, the query will return all records from record 20 on. If fewer than 20 records are available, none will be returned.
&lt;p&gt;SQL Server does not have this functionality, however the 2005 release does have a number of other new tricks. For instance, support for CLR procedures means it is possible to use existing paging methods to write VB.NET or C# code that would execute within the SQL Server environment. Unfortunately, CLR procedures are not as efficient as native Transact SQL. To ensure best performance, queries should still be written in TSQL whenever practical.
&lt;p&gt;Using ROW_NUMBER()
&lt;p&gt;TSQL in the 2005 release includes the ROW_NUMBER() function, which adds an integer field to each record with the record&#39;s ordinal result set number. Stated more simply, it adds the record&#39;s position within the result set as an additional field so that the first record has a 1, the second a 2, etc. This may appear to be of little value, however by using nested queries we can use this to our advantage.
&lt;p&gt;To demonstrate ROW_NUMBER() and to explore how the paging solution works, create a simple salary table and populate it with random data using the following commands:&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;TABLE&lt;/span&gt; [dbo].[Salaries](
    [person] [nvarchar](50) &lt;span class=&quot;kwrd&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;NULL&lt;/span&gt;,
    [income] [money] &lt;span class=&quot;kwrd&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;NULL&lt;/span&gt;,
 &lt;span class=&quot;kwrd&quot;&gt;CONSTRAINT&lt;/span&gt; [PK_salaries] &lt;span class=&quot;kwrd&quot;&gt;PRIMARY&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;KEY&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;CLUSTERED&lt;/span&gt;(
    [person] &lt;span class=&quot;kwrd&quot;&gt;ASC&lt;/span&gt;
)) &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; [&lt;span class=&quot;kwrd&quot;&gt;PRIMARY&lt;/span&gt;]
&lt;span class=&quot;kwrd&quot;&gt;GO&lt;/span&gt;

INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Joe&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;28000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Sue&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;96000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Michael&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;45000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;John&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;67000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Ralph&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;18000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Karen&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;73000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Waldo&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;47000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Eva&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;51000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Emerson&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;84000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Stanley&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;59000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Jorge&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;48000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Constance&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;51000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Amelia&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;36000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Anna&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;49000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Danielle&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;68000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Stephanie&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;47000&#39;&lt;/span&gt;)
INSERT &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; Salaries &lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt; (&lt;span class=&quot;str&quot;&gt;&#39;Elizabeth&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;23000&#39;&lt;/span&gt;)&lt;/pre&gt;
&lt;p&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;The ROW_NUMBER() function has no parameters - it simply adds the row number to each record in the result set. To ensure the numbering is consistent, however, SQL Server needs to know how to sort the data. Because of this, ROW_NUMBER() must immediately be followed by the OVER() function. OVER() has one required parameter, which is an ORDER BY clause. The basic syntax for querying the Salaries table is:&lt;/p&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; ROW_NUMBER() &lt;span class=&quot;kwrd&quot;&gt;OVER&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; person), person, income
&lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; Salaries&lt;/pre&gt;
&lt;p&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;This returns the following result:&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;(No column name)    person    income&lt;/pre&gt;&lt;pre&gt;1    Amelia    36000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;2    Anna    49000.00&lt;/pre&gt;&lt;pre&gt;3    Constance    51000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;4    Danielle    68000.00&lt;/pre&gt;&lt;pre&gt;5    Elizabeth    23000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;6    Emerson    84000.00&lt;/pre&gt;&lt;pre&gt;7    Eva    51000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;8    Joe    28000.00&lt;/pre&gt;&lt;pre&gt;9    John    67000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;10    Jorge    48000.00&lt;/pre&gt;&lt;pre&gt;11    Karen    73000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;12    Michael    45000.00&lt;/pre&gt;&lt;pre&gt;13    Ralph    18000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;14    Stanley    59000.00&lt;/pre&gt;&lt;pre&gt;15    Stephanie    47000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;16    Sue    96000.00&lt;/pre&gt;&lt;pre&gt;17    Waldo    47000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;The Salaries data now appears sorted by person, and it has an extra column indicating each record&#39;s position within the results.&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;If &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; any reason you wanted the results to display &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; a different order than they were numbered &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt;, you can include a different ORDER BY clause &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; part of the normal SELECT syntax:&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; ROW_NUMBER() &lt;span class=&quot;kwrd&quot;&gt;OVER&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; person), person, income 
&lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; Salaries 
&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; income&lt;/pre&gt;
&lt;p&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;This returns the following result:&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;(No column name)    person    income&lt;/pre&gt;&lt;pre&gt;13    Ralph    18000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;5    Elizabeth    23000.00&lt;/pre&gt;&lt;pre&gt;8    Joe    28000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;1    Amelia    36000.00&lt;/pre&gt;&lt;pre&gt;12    Michael    45000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;15    Stephanie    47000.00&lt;/pre&gt;&lt;pre&gt;17    Waldo    47000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;10    Jorge    48000.00&lt;/pre&gt;&lt;pre&gt;2    Anna    49000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;3    Constance    51000.00&lt;/pre&gt;&lt;pre&gt;7    Eva    51000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;14    Stanley    59000.00&lt;/pre&gt;&lt;pre&gt;9    John    67000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;4    Danielle    68000.00&lt;/pre&gt;&lt;pre&gt;11    Karen    73000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;6    Emerson    84000.00&lt;/pre&gt;&lt;pre&gt;16    Sue    96000.00&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;If we want to limit the results displayed to a certain range, we need to nest this SELECT inside another one and provide a name for the ROW_NUMBER() column. To limit our results to records 5 through 9, we can use the following query:&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class=&quot;csharpcode&quot;&gt;SELECT *
FROM   (SELECT ROW_NUMBER() OVER(ORDER BY person) AS 
       rownum, person, income FROM Salaries) AS Salaries1
WHERE  rownum &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;= 5 AND rownum &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;= 9

This returns the following result:

rownum    person    income
5    Elizabeth    23000.00
6    Emerson    84000.00
7    Eva    51000.00
8    Joe    28000.00
9    John    67000.00
Again, we can change the sort order by adding an ORDER BY clause. This is most easily accomplished by using the outer SELECT statement:

SELECT *
FROM   (SELECT ROW_NUMBER() OVER(ORDER BY person) AS
       rownum, person, income FROM Salaries) AS Salaries1
WHERE  rownum &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;= 5 AND rownum &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;= 9
ORDER BY income

This returns the following result:

rownum    person    income
5    Elizabeth    23000.00
8    Joe    28000.00
7    Eva    51000.00
9    John    67000.00
6    Emerson    84000.00
If we want to support the same type of arguments that MySQL&#39;s LIMIT() supports, we can create a stored procedure that accepts a beginning point and a maximum number of records to return. ROW_NUMBER requires that the data be sorted, so we will also have a required parameter for the ORDER BY clause. Execute the following statement to create a new stored procedure:

CREATE PROCEDURE [dbo].[pageSalaries]
  @start  int = 1
 ,@maxct  int = 5
 ,@sort   nvarchar(200)
AS
  SET NOCOUNT ON
  DECLARE
    @STMT nvarchar(max),    -- SQL statement to execute
    @ubound int

  IF @start &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt; 1 SET @start = 1
  IF @maxct &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt; 1 SET @maxct = 1
  SET @ubound = @start + @maxct
  SET @STMT = &#39; SELECT person, income
                FROM (
                      SELECT  ROW_NUMBER() OVER(ORDER BY &#39; + @sort + &#39;) AS row, *
                      FROM    Salaries
                     ) AS tbl
                WHERE  row &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;= &#39; + CONVERT(varchar(9), @start) + &#39; AND
                       row &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;  &#39; + CONVERT(varchar(9), @ubound)
  EXEC (@STMT)              -- return requested records 

The pageSalaries procedure begins with SET NOCOUNT ON to disable the record count message (a common step for optimizing query performance). We then declare two necessary variables, @STMT and @ubound. Because we want to be able to change what ORDER BY argument is used, we need to dynamically generate our query statement by storing it in @STMT. The next lines ensure that only positive numbers are used for the starting position and maximum size, then calculate the range of ROW_NUMBER() values being requested. (If we wanted to be zero-based like MySQL&#39;s LIMIT, we could do so with a few minor tweaks.) Once the dynamic SQL command has been strung together, it is executed so that the results are returned.

Execute the following statement to test the stored procedure:

pageSalaries 4, 7, &#39;income&#39;

This returns the following result:

person    income
Amelia    36000.00
Michael    45000.00
Stephanie    47000.00
Waldo    47000.00
Jorge    48000.00
Anna    49000.00
Constance    51000.00
If we execute:

pageSalaries 13, 7, &#39;income&#39;

we receive back:

person    income
John    67000.00
Danielle    68000.00
Karen    73000.00
Emerson    84000.00
Sue    96000.00
... because the query goes beyond the number of records available.

Taking this one step further, we can make a stored procedure that does a more general form of paging. In fact, it can be generalized to the point that it can be used to return any collection of fields, in any order, with any filtering clause. To create this wunderkind marvel, execute the following command:

CREATE PROCEDURE [dbo].[utilPAGE]
  @datasrc nvarchar(200)
 ,@orderBy nvarchar(200)
 ,@fieldlist nvarchar(200) = &#39;*&#39;
 ,@filter nvarchar(200) = &#39;&#39;
 ,@pageNum int = 1
 ,@pageSize int = NULL
AS
  SET NOCOUNT ON
  DECLARE
     @STMT nvarchar(max)         -- SQL to execute
    ,@recct int                  -- total # of records (for GridView paging interface)

  IF LTRIM(RTRIM(@filter)) = &#39;&#39; SET @filter = &#39;1 = 1&#39;
  IF @pageSize IS NULL BEGIN
    SET @STMT =  &#39;SELECT   &#39; + @fieldlist + 
                 &#39;FROM     &#39; + @datasrc +
                 &#39;WHERE    &#39; + @filter + 
                 &#39;ORDER BY &#39; + @orderBy
    EXEC (@STMT)                 -- return requested records 
  END ELSE BEGIN
    SET @STMT =  &#39;SELECT   @recct = COUNT(*)
                  FROM     &#39; + @datasrc + &#39;
                  WHERE    &#39; + @filter
    EXEC sp_executeSQL @STMT, @params = N&#39;@recct INT OUTPUT&#39;, @recct = @recct OUTPUT
    SELECT @recct AS recct       -- return the total # of records

    DECLARE
      @lbound int,
      @ubound int

    SET @pageNum = ABS(@pageNum)
    SET @pageSize = ABS(@pageSize)
    IF @pageNum &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt; 1 SET @pageNum = 1
    IF @pageSize &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt; 1 SET @pageSize = 1
    SET @lbound = ((@pageNum - 1) * @pageSize)
    SET @ubound = @lbound + @pageSize + 1
    IF @lbound &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;= @recct BEGIN
      SET @ubound = @recct + 1
      SET @lbound = @ubound - (@pageSize + 1) -- return the last page of records if                                               -- no records would be on the
                                              -- specified page
    END
    SET @STMT =  &#39;SELECT  &#39; + @fieldlist + &#39;
                  FROM    (
                            SELECT  ROW_NUMBER() OVER(ORDER BY &#39; + @orderBy + &#39;) AS row, *
                            FROM    &#39; + @datasrc + &#39;
                            WHERE   &#39; + @filter + &#39;
                          ) AS tbl
                  WHERE
                          row &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &#39; + CONVERT(varchar(9), @lbound) + &#39; AND
                          row &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt; &#39; + CONVERT(varchar(9), @ubound)
    EXEC (@STMT)                 -- return requested records 
  END

You may receive the following error message from SQL Server, which you can confidently ignore:

Cannot add rows to sys.sql_dependencies for the stored procedure because it depends on the missing table &#39;sp_executeSQL&#39;. The stored procedure will still be created; however, it cannot be successfully executed until the table exists.
The utilPage procedure accepts 6 parameters:

@datasrc            - the table (or stored procedure, etc.) name
@orderBy    - the ORDER BY clause
@fieldlis    - the fields to return (including calculated expressions)
@filter    - the WHERE clause
@pageNum    - the page to return (must be greater than or equal to one)
@pageSize    - the number of records per page
The stored procedure needs the name of a data source to query against (such as a table) and one or more fields to sort by (since OVER() requires an ORDER BY clause). If @filter is blank (the default), it will be set to &quot;1 = 1&quot; as a simple way to select all records. If @pageSize is not supplied, the query will run without paging and will not return a record count.

If, however, @pageSize is supplied, a version of the query is executed to get the total number of records. In order to have this record count available within the procedure and as a returned value, we use sp_executeSQL to support executing the statement while returning an output parameter. The record count is used to prevent returning empty results when possible, and to support paging interfaces that calculate the number of pages available (such as GridView). If we were calling this stored procedure to populate a GridView, we would return @recct as a ReturnValue parameter instead of using a result set, but we will use a result set for demonstration purposes.

The procedure calculates what the actual record positions will be for the requested page. Rather than allow the query to fail, there are safety checks ensuring that @pageSize and @pageNum are greater than zero, and that the result set will not be empty. If the specified page is out of range, this procedure will return the last possible page of records. This is helpful if a user changes more than one setting before refreshing their data, or if a significant amount of data is deleted between requests.

The remainder of the procedure is virtually identical to the pageSalaries procedure. To test the utilPAGE stored procedure, execute the following statement:

utilPAGE &#39;Salaries&#39;, &#39;person&#39;, &#39;*&#39;, &#39;income &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; 1000&#39;, 2, 4

This returns the following two result sets:

recct
17

row    person    income
5    Elizabeth    23000
6    Emerson    84000
7    Eva    51000
8    Joe    28000
If we execute:

utilPAGE &#39;Salaries&#39;, &#39;person&#39;, &#39;person, income&#39;, &#39;&#39;, 13, 3

...we receive back:

recct
17

person    income
Stephanie    47000
Sue    96000
Waldo    47000
Even though the request should be for records 36 through 38 - far outside of what is available - the procedure returns the last available page of records. In contrast, requesting the third page with seven records per page using:

utilPAGE &#39;Salaries&#39;, &#39;person&#39;, &#39;person, income&#39;, &#39;&#39;, 3, 7

...returns the last three records, as the page is not completely out of bounds:

person    income
Stephanie    47000
Sue    96000
Waldo    47000
All of these examples are based on simple single-table queries, which may not reflect what you need in the real world. While the utilPAGE procedure does not support ad-hoc JOINs, it does work with SQL Views. If you want paging support for multi-table queries, you should create a View (with all of the necessary JOINs) to use as the data source. Using a View follows good design practices as it ensures that your Joins are performed consistently, allows easier ad-hoc querying from the command line, and is much easier to troubleshoot than a stored procedure&#39;s dynamic SELECT statement logic.

Conclusion


While SQL Server does not have as simple a method for paging results as some other databases, features introduced in the 2005 release have made it possible to page results efficiently more easily than ever before. In the next article in this series, we will go a step further and integrate this paging logic with a GridView through a Data Access Layer. 

------------------------------------------------------------&lt;/pre&gt;
&lt;p&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/p&gt;&lt;pre class=&quot;csharpcode&quot;&gt;Demo:

&lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt; ANSI_NULLS &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt; QUOTED_IDENTIFIER &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;go&lt;/span&gt;

 

 

&lt;span class=&quot;rem&quot;&gt;-- =============================================       &lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;-- Author:  TaiTD     &lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;-- Create date: 02/02/2010&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;-- Description: Export to XML file       &lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;-- =============================================       &lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;proc&lt;/span&gt; [dbo].[GetDELETEDJobPostingsBy_JobTypeID]       

(

      @JobTypeID &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;

)

&lt;span class=&quot;kwrd&quot;&gt;As&lt;/span&gt;       

&lt;span class=&quot;kwrd&quot;&gt;Begin&lt;/span&gt;     

 

      &lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; *

      &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt;   (&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; ROW_NUMBER() &lt;span class=&quot;kwrd&quot;&gt;OVER&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; del.JobPostingID) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt;

               rownum, del.JobPostingID, del.Title, del.Description, del.IsSearchable, JT.JobTypeID, JST.JobSubTypeID,

                  JT.JobTypeKey, JST.JobSubtypeKey, com.CompanyName, com.CompanyProfile

                  &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; DELETED_JobPostings &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; del

                  &lt;span class=&quot;kwrd&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt; Web_Companies &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; com &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; del.CompanyID = com.CompanyID

                  &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt; DELETED_JobPostings_Types &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; delJPT &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; delJPT.JobPostingID = del.JobPostingID

                  &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt; Web_JobSubtypes &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; JST &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; JST.JobSubtypeID = delJPT.JobSubtypeID

                  &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt; Web_JobTypes &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; JT &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; JT.JobTypeID = JST.JobTypeID ) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; OOOOO

      &lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; IsSearchable=1 &lt;span class=&quot;kwrd&quot;&gt;and&lt;/span&gt; LEN(Description)&amp;gt;100 &lt;span class=&quot;kwrd&quot;&gt;and&lt;/span&gt; rownum &amp;gt;= 1 &lt;span class=&quot;kwrd&quot;&gt;AND&lt;/span&gt; rownum &amp;lt;= 170000 &lt;span class=&quot;kwrd&quot;&gt;and&lt;/span&gt; JobTypeID=@JobTypeID

           

&lt;span class=&quot;kwrd&quot;&gt;End&lt;/span&gt;

 

------------&lt;span class=&quot;rem&quot;&gt;--&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          SELECT top 9000 del.JobPostingID, del.Title, del.Description, del.IsSearchable, JT.JobTypeID, JST.JobSubTypeID,&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          JT.JobType, JST.JobSubType, com.CompanyName, com.CompanyProfile&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          FROM DELETED_JobPostings as del&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          INNER JOIN Web_Companies as com ON del.CompanyID = com.CompanyID&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          JOIN DELETED_JobPostings_Types as delJPT ON delJPT.JobPostingID = del.JobPostingID&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          JOIN Web_JobSubtypes as JST ON JST.JobSubtypeID = delJPT.JobSubtypeID&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          JOIN Web_JobTypes as JT ON JT.JobTypeID = JST.JobTypeID&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          WHERE del.IsSearchable=1 and LEN(del.Description)&amp;gt;100 and JT.JobTypeID=@JobTypeID&lt;/span&gt;

--------------&lt;span class=&quot;rem&quot;&gt;--&lt;/span&gt;

--&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; *

--&lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt;   (&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; ROW_NUMBER() &lt;span class=&quot;kwrd&quot;&gt;OVER&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; JobPostingID) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--       rownum, JobPostingID, Title FROM DELETED_JobPostings) AS del&lt;/span&gt;

--&lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt;  rownum &amp;gt;= 5 &lt;span class=&quot;kwrd&quot;&gt;AND&lt;/span&gt; rownum &amp;lt;= 9

--------------&lt;span class=&quot;rem&quot;&gt;--&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--&lt;/span&gt;

--&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; *

--&lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt;   (&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; ROW_NUMBER() &lt;span class=&quot;kwrd&quot;&gt;OVER&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; del.JobPostingID) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--       rownum, del.JobPostingID, del.Title, del.Description, del.IsSearchable, JT.JobTypeID, JST.JobSubTypeID,&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          JT.JobType, JST.JobSubType, com.CompanyName, com.CompanyProfile&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          FROM DELETED_JobPostings as del&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          INNER JOIN Web_Companies as com ON del.CompanyID = com.CompanyID&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          JOIN DELETED_JobPostings_Types as delJPT ON delJPT.JobPostingID = del.JobPostingID&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          JOIN Web_JobSubtypes as JST ON JST.JobSubtypeID = delJPT.JobSubtypeID&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;--          JOIN Web_JobTypes as JT ON JT.JobTypeID = JST.JobTypeID ) AS OOOOO&lt;/span&gt;

--&lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; IsSearchable=1 &lt;span class=&quot;kwrd&quot;&gt;and&lt;/span&gt; LEN(Description)&amp;gt;100 &lt;span class=&quot;kwrd&quot;&gt;and&lt;/span&gt; JobTypeID=@JobTypeID &lt;span class=&quot;kwrd&quot;&gt;and&lt;/span&gt; rownum &amp;gt;= 5 &lt;span class=&quot;kwrd&quot;&gt;AND&lt;/span&gt; rownum &amp;lt;= 9

------------------&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/paging-in-sql-server-2005-rownumber.html</link><author>noreply@blogger.com (Truong Duc Tai)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-2572743158523813273</guid><pubDate>Mon, 14 May 2012 03:57:00 +0000</pubDate><atom:updated>2012-05-14T19:12:59.755+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Blogger Tips and Tricks</category><title>Add Social Sharing Button to Blogger</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;/div&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;img alt=&quot;Messenger&quot; class=&quot;wlEmoticon wlEmoticon-messenger&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigYF43MpIacIZrexwWfoi2vynI60344EWauzz6gw1-ucIqVVso6xqMCz55675F2RiRa_SgkGn0k-FzZFMe3DVoyqrLpBSn0gFaMnCSvrFtE1B-HC7PjJEz4P5-h0A9I94rjvhI7XFBFg/?imgmax=800&quot; style=&quot;border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none;&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;post-share&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;Save And Share : &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://twitter.com/intent/tweet?text=&amp;amp;quot; + data:post.title + &amp;amp;quot;&amp;amp;amp;url=&amp;amp;quot; + data:post.url&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Tweet This !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Tweet This !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCcBZqLbjK3fBwQnjANcDxKkSeNtPQ5aNpDrUn4X3PiiCQy4p_fE_wXPVexWGioTTipnNb60XXCZUoXLPFfdIqpR9j-TG8J-bsejM8nu_ImMnuRsI0xRweVbHnfsgbdAiFTaiiQ7wCsuY/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;height:16px; width:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://www.facebook.com/sharer.php?u=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;t=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Facebook !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Facebook !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjURNYcuObzGHoRjtwTqr2znKyzLZz0xvccAA-48DsZn9WCjqBKx3Oc-765djMXMdss1y9Xc-pTWfGE5N71mqCiAbLiVDXc4eThdjhUlp8Fx7ogCMU7pc6J8GowxwCeWq0dxMubZu0VMO0/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;https://plusone.google.com/_/+1/confirm?hl=&amp;amp;quot; + &amp;amp;quot;en&amp;amp;amp;url=&amp;amp;quot; + data:post.url&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Google Plus !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Google Plus !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaV54Zgh8PheChwosthA_pTnHIRoPZz3NqcYVXUSYrFqvxE2oa0v4wiiKTY7QB6CcBYBZPpAM2lyrMlViHOXBY02gFgk_fhh2hehnBm73wyWaygdrpXDmWeMoJEin4muOAmgXS_XI12uY/s16/icon-google-plus.gif&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://del.icio.us/post?url=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;title=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Add To Del.icio.us !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Add To Del.icio.us !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiBPkbvMGGEkwDN62YuoF4ep8V1s8EFz-zmZiQDiPVR4v0kRlxkGGorNp40vCV5K5vt_RFCWgzefsQCMtNgV-b4xWWLenHO2OZyY3xQRaiHSvGEBhyphenhyphenAeBV38GQebH42XIh8dEkGbZXaec/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://www.stumbleupon.com/submit?url=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;title=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On StumbleUpon !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On StumbleUpon !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://lh3.googleusercontent.com/-uXMuiLzxoFM/T25RKdHPgoI/AAAAAAAAARg/iU-TbKOb174/s16/stumble-new.gif&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  15:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://digg.com/submit?phase=&amp;amp;quot; + &amp;amp;quot;2&amp;amp;amp;url=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;title=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Digg !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Digg !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsHf71cFfhaR41ZqVFrpfchm1ZEva5lcG5feIaq7vNdLImBdcnzax6_3vZI0fFQ5KdCeSSj05k15ihbekdeOJ0u6CORqS0LqmlkFenr9iPpf1zlZwSGaj_LtK_74iisTXiMqm7oBpQKcM/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  16:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  17:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://pinterest.com/pin/create/button/?url=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;title=&amp;amp;quot; + data:post.title + &amp;amp;quot;&amp;amp;amp;is_video=&amp;amp;quot;&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Pin It !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Pin It !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtTalRNJBvJvILFUXp3tzrduELUyN9mcVvugtCKM96Y4XwsADcAW6-RqLR9lcLYRhta4fgk9uPmvqQnZ3U1-w2w-iVOiNK7UurZcwTfVBm3ioRVYQJSQiW2asro_J8KiiUq3Uxt2mbGMc/s16/pinterest-button.gif&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  18:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  19:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://reddit.com/submit?url=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;title=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Reddit !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Reddit !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3LUJKCEpvwgJf_yv2pLK4aBusD_TJgXaFsJKPjXar2HwbKSfHPuJxJeAg1W0Nx85J3NL5CYikYQyfEWa5e7W1vYif2qktzDHd9yIyjby-eN5BmHHTzQjSpLXfl0l4HB8Pw2aV5hl-38U/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  20:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  21:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://www.linkedin.com/shareArticle?mini=&amp;amp;quot; + &amp;amp;quot;true&amp;amp;amp;url=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;title=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On LinkedIn !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On LinkedIn !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5kgu05yH5Hvol5imREiYO_mh3nkB8rK2IAm0gk9Alol80d0_wxh0CTdop_CNsVnJjlDGqFDakKEGZzZ7T13Sl-BJihWvJXECS24bxNqq8YfdQDyeym6xAidT9XGIJkLx4w6hkQ1yPCBI/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  22:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  23:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://www.blogger.com/blog_this.pyra?t&amp;amp;quot; + &amp;amp;quot;&amp;amp;amp;u=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;n=&amp;amp;quot; + data:post.title + &amp;amp;quot;&amp;amp;amp;pli=&amp;amp;quot; + 1&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Post To Blogger !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Post To Blogger !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMAtYCJnak2wbWGkCFecaKE-s1QbiniMzY0qgXCZbVxWyn2RBpPs3HbZk6kHUt0f2bPkxvljKtTu7SxcGXq1L0OyPVxw6n0VHhSpO421L-aWQiZhAHW4-5Pu_18JCYIVnDrKvlpleAk18/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  24:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  25:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://www.friendfeed.com/share?link=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;title=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Friend Feed !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Friend Feed !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-IF_VAEiyeJKl7BxcB0boFcuASdNELRSNeyzfhhoybm1k3ZRCVFHzgsZS5AuDVqrHMZ5KZ8OyQRTwzX_W4B6j4FGTD3xpHNMLat35FAOV5BKWyJoYMDfUkWcD4KTV6Hv-BuT5Ns2P6z0/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  26:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  27:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://www.myspace.com/Modules/PostTo/Pages/?u=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;t=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On MySpace !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On MySpace !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3vfyoYKFRk7olcZ0cQnjB_SQfYa-TDbUygd_hKK0PIbhBCLvjHutJWAsgz_PxSxroFu7e9h4JhtcD9-JYG7dHRtfuw_75_JSK6xc_UTXXYo596N0bGFLk9PRk5P7GZxOxkpkk8uCdWC4/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  28:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  29:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://buzz.yahoo.com/buzz?targetUrl=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;headline=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Yahoo Buzz !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Share On Yahoo Buzz !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpXBRsn2aUEIdVbVui3fHoOYavx0Vzv3mxOTVFErJxge-ccYULV40ar4PT6Mi3Cr0lexUQsgZA1-dk5NqT09p9BK_iPfJPZlxdOUMXU82cCtgFtzXyIxMJKu8cWMp3qnh2NekZ5f-VNkc/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  30:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  31:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;http://love4all1080.blogspot.com/2010/01/simple-share-buttons-for-blogger.html&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Get These Share Buttons !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Get These Share Buttons !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPfEK2VNAbQPk5xums_gSjuwj1Rw4iUe8CCVBbDfsBzKMwzY3MhPQ_jgaggRLUbUYkVROC6IVfrGTI30BraxydEU3zLKIm55LTHGulP06wJYE9GXvNQXkJaPy-aYSc5e7cVE-OprtUtlI/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  32:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  33:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://www.google.com/bookmarks/mark?op=&amp;amp;quot; + &amp;amp;quot;add&amp;amp;amp;bkmk=&amp;amp;quot; + data:post.url + &amp;amp;quot;&amp;amp;amp;title=&amp;amp;quot; + data:post.title&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Google Bookmark !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Google Bookmark !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1b9DcMseWLBU7MRfCqq59jX3Q0rJpZv-ZsQt0f4EVzigjNee56LngQDZ54kKYd6wdbh1JAIT0GsjuE1BLbE5DYorU1uPylYCisKGddUrnPB6Bw8FqdBhYYd4-JewTAi9QgV0PSkjA7EU/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  34:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  35:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;&amp;amp;quot;http://www.printfriendly.com/print/v2?url=&amp;amp;quot; + data:post.url&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Create PDF And Print Friendly !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Create PDF And Print Friendly !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJd4eHcVAARNiMX1g4XFosuQ3dTcNoYH8q1RHTagXMs1oXY3j5o9GcqES2KgUyo6dFLca2LbOP94iNCdlopYjr9rJLIYGlDRLb5yTrWsKwWzKAd76MYHDn1OQZj3BtIEyUwpMmGC-AqOc/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  36:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  37:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;expr:href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;data:blog.homepageUrl + &amp;amp;quot;feeds/posts/default&amp;amp;quot;&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;_blank&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Blog Feed !&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;Blog Feed !&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyzVfksL2mSuQoRh75q-7QWwic9Sm8zrEB8P5Uce9Q_aP734ably0ccu5PB3y6aDtMMAjVUdcLRH_zOgHW_EzbCXnkt0wfB9WGG6BdjnpW7JW54mKMMSfv7-uRpkpySyNqJbqKDW2kX0o/&#39;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;width:16px; height:16px; padding:0; border:0; vertical-align:middle;&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  38:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  39:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style type=&quot;text/css&quot;&gt;
.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, &quot;Courier New&quot;, courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/add-social-sharing-button-to-blogger.html</link><author>noreply@blogger.com (Johnson William)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigYF43MpIacIZrexwWfoi2vynI60344EWauzz6gw1-ucIqVVso6xqMCz55675F2RiRa_SgkGn0k-FzZFMe3DVoyqrLpBSn0gFaMnCSvrFtE1B-HC7PjJEz4P5-h0A9I94rjvhI7XFBFg/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-2056404828215342598</guid><pubDate>Sun, 13 May 2012 22:09:00 +0000</pubDate><atom:updated>2012-05-14T05:09:53.170+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Thuật toán sắp xếp mảng</title><description>&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; ConsoleApplication1
{
    &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Question1
    {
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;[] arrA;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; FindNumber(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; n)
        {
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; result = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
            {
                &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i;
                &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; j;
                &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; tmp;
                arrA = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;[n];
                &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (i = 0; i &amp;lt; n; i++)
                {
                    Console.Write(&lt;span class=&quot;str&quot;&gt;&quot;\n\tNhap vao phan tu thu &quot;&lt;/span&gt; + (i + 1)+&lt;span class=&quot;str&quot;&gt;&quot;: &quot;&lt;/span&gt;);
                    arrA[i] = &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;.Parse(Console.ReadLine());
                }

                &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (i = 0; i &amp;lt; n - 1; i++)
                {
                    &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (j = i + 1; j &amp;lt; n; j++)
                    {
                        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (arrA[i] &amp;gt; arrA[j])
                        {
                            tmp = arrA[i];
                            arrA[i] = arrA[j];
                            arrA[j] = tmp;    &lt;span class=&quot;rem&quot;&gt;//doi cho a[i] va a[j]&lt;/span&gt;
                        }
                    }                                    
                }
                &lt;span class=&quot;rem&quot;&gt;// in ra mang da sap xep theo thu tu tang dan&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (i = 0; i &amp;lt; n; i++)
                {                    
                    result += arrA[i]+&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;;
                    &lt;span class=&quot;rem&quot;&gt;//Sap xep giam dan&lt;/span&gt;
                    &lt;span class=&quot;rem&quot;&gt;//result += arrA[n-(i+1)]+&quot; &quot;;&lt;/span&gt;
                }                
            }
            &lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (Exception ex)
            {
                result = ex.Message;
            }
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; result;
        }

    }
}

---------------------------------------------------------------------------------------

&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; ConsoleApplication1
{
    &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Program
    {
        &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Main(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;[] args)
        {
            Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Nhap so phan tu cua mang so nguyen:&quot;&lt;/span&gt;);
            &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; n = &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;.Parse(Console.ReadLine());

            Question1 q = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Question1();
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; result = q.FindNumber(n);
            Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;KET QUA SAP XEP TANG DAN: &quot;&lt;/span&gt;+result);
            Console.ReadLine();
        }
    }
}

Cách 2

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;

        &lt;span class=&quot;rem&quot;&gt;/// Sorting an input array&lt;/span&gt;

        &lt;span class=&quot;rem&quot;&gt;/// the output would be another array with sorted by ascending&lt;/span&gt;

        &lt;span class=&quot;rem&quot;&gt;/// for example : input: 1,3,2 -&amp;gt; the output would be 1,2,3&lt;/span&gt;

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;Str_ListBox&quot;&amp;gt;the input array&amp;lt;/param&amp;gt;&lt;/span&gt;

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;returns&amp;gt;the output with sorted items&amp;lt;/returns&amp;gt;&lt;/span&gt;

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; GetSortedArray(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; sourceString)

        {

            List&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;&amp;gt; lstSource = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; List&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;&amp;gt;();

            &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; s &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; sourceString.Split(&lt;span class=&quot;str&quot;&gt;&#39;,&#39;&lt;/span&gt;))

            {

                lstSource.Add(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;.Parse(s));

            }

            lstSource.Sort();

            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; ConvertListObjectToString(lstSource);

        }&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/thuat-toan-sap-xep-mang.html</link><author>noreply@blogger.com (Truong Duc Tai)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-6590253675548227441</guid><pubDate>Sun, 13 May 2012 22:09:00 +0000</pubDate><atom:updated>2012-05-14T05:09:00.333+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><title>ASP.NET: Tạo bộ tìm kiếm gần đúng (tương đối) giống như tamtay.vn, google.com</title><description>&lt;pre class=&quot;csharpcode&quot;&gt;Default.aspx

&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text-align: center&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;color: #ff6600&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;strong&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;TÌM KIẾM TƯƠNG ĐỐI&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;strong&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;font-size: 10pt; font-family: Verdana&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        Nhập từ cần tìm:&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:TextBox&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;TextBox1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;421px&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:TextBox&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Button&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;btnSeach&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Seach&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;OnClick&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;btnSeach_Click&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;hr&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Label&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;lblSQL&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Label&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;hr&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;Default.aspx.cs

&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Data;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Configuration;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web;
&lt;span class=&quot;rem&quot;&gt;/// Author: Trương Đức Tài&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// 09/11/2009 (dd/mm/yyy)&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// Phone: 0979.116118&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.Security;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.HtmlControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; TimKiemGanDung.Utilities;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; TimKiemGanDung
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; _Default : System.Web.UI.Page
    {
        &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
        {

        }

        &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; btnSeach_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; keyWord = TextBox1.Text;
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; sql = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty;
               
            sql = SearchApproximate.ApproximateSearch(keyWord);
            lblSQL.Text = sql;

            &lt;span class=&quot;rem&quot;&gt;// Khi có được chuỗi sql như trên các bạn biết phải làm gì rồi chứ?&lt;/span&gt;
            &lt;span class=&quot;rem&quot;&gt;// Thanks!&lt;/span&gt;
        }
    }
}

SearchApproximate.cs

&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Data;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Configuration;
&lt;span class=&quot;rem&quot;&gt;/// Author: Trương Đức Tài&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// 09/11/2009 (dd/mm/yyy)&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// Phone: 0979.116118&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.Security;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.HtmlControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; TimKiemGanDung.Utilities
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; SearchApproximate
    {
        &lt;span class=&quot;rem&quot;&gt;// Phương thức trả về câu lệnh SQL dùng truy vấn dữ liệu&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; ApproximateSearch(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; keyWord)
        {
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; sql = &lt;span class=&quot;str&quot;&gt;&quot;SELECT * FROM Employer WHERE FullName LIKE &quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; sql + &lt;span class=&quot;str&quot;&gt;&quot;N&#39;&quot;&lt;/span&gt; + Exec(keyWord) + &lt;span class=&quot;str&quot;&gt;&quot;&#39; OR FullName LIKE N&#39;&quot;&lt;/span&gt; + Exec(ConvertVN.Convert(keyWord)) + &lt;span class=&quot;str&quot;&gt;&quot;&#39;&quot;&lt;/span&gt;;
        }

        &lt;span class=&quot;rem&quot;&gt;// Phương thức chuyển đổi một chuỗi ký tự: Nếu chuỗi đó có ký tự &quot; &quot; sẽ thay thế bằng &quot;%&quot;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Exec(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; keyWord)
        {
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;[] arrWord = keyWord.Split(&lt;span class=&quot;str&quot;&gt;&#39; &#39;&lt;/span&gt;);
            StringBuilder str = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; StringBuilder(&lt;span class=&quot;str&quot;&gt;&quot;%&quot;&lt;/span&gt;);
            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; arrWord.Length; i++)
            {
                str.Append(arrWord[i] + &lt;span class=&quot;str&quot;&gt;&quot;%&quot;&lt;/span&gt;);
            }
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; str.ToString();
        }
    }
}

ConvertVN.cs

&lt;span class=&quot;rem&quot;&gt;/// Author: Trương Đức Tài&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// 09/11/2009 (dd/mm/yyy)&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// Phone: 0979.116118&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Data;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Configuration;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.Security;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.HtmlControls;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; TimKiemGanDung.Utilities
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; ConvertVN
    {
        &lt;span class=&quot;rem&quot;&gt;// Phương thức Convert một chuỗi ký tự Có dấu sang Không dấu&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Convert(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; chucodau)
        {
            &lt;span class=&quot;kwrd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; FindText = &lt;span class=&quot;str&quot;&gt;&quot;áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; ReplText = &lt;span class=&quot;str&quot;&gt;&quot;aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; index = -1;
            &lt;span class=&quot;kwrd&quot;&gt;char&lt;/span&gt;[] arrChar = FindText.ToCharArray();
            &lt;span class=&quot;kwrd&quot;&gt;while&lt;/span&gt; ((index = chucodau.IndexOfAny(arrChar)) != -1)
            {
                &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; index2 = FindText.IndexOf(chucodau[index]);
                chucodau = chucodau.Replace(chucodau[index], ReplText[index2]);
            }
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; chucodau;
        }
    }
}

Mã nguồn tải tại đây

(Đã hoàn thành 99%, các bạn hãy chạy thử và hoàn thành tiếp bộ tìm kiếm với kết nối CSDL nhé)
Author: Trương Đức Tài&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/aspnet-tao-bo-tim-kiem-gan-ung-tuong-oi.html</link><author>noreply@blogger.com (Truong Duc Tai)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-7196711839062710343</guid><pubDate>Sun, 13 May 2012 22:07:00 +0000</pubDate><atom:updated>2012-05-14T05:07:31.621+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Convert chữ tiếng việt có dấu thành không dấu C#</title><description>&lt;pre class=&quot;csharpcode&quot;&gt;Hàm dùng để convert chữ tiếng việt có dấu thành chữ tiếng việt không dấu.

&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; ConvertVN(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; chucodau)
    {
        &lt;span class=&quot;kwrd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; FindText = &lt;span class=&quot;str&quot;&gt;&quot;áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ&quot;&lt;/span&gt;;
        &lt;span class=&quot;kwrd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; ReplText = &lt;span class=&quot;str&quot;&gt;&quot;aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY&quot;&lt;/span&gt;;
        &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; index = -1;
        &lt;span class=&quot;kwrd&quot;&gt;char&lt;/span&gt;[] arrChar = FindText.ToCharArray();
        &lt;span class=&quot;kwrd&quot;&gt;while&lt;/span&gt; ((index = chucodau.IndexOfAny(arrChar)) != -1)
        {
            &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; index2 = FindText.IndexOf(chucodau[index]);
            chucodau = chucodau.Replace(chucodau[index], ReplText[index2]);
        }
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; chucodau;
    } &lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/convert-chu-tieng-viet-co-dau-thanh.html</link><author>noreply@blogger.com (Truong Duc Tai)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-5846013711893287107</guid><pubDate>Sun, 13 May 2012 22:06:00 +0000</pubDate><atom:updated>2012-05-14T05:06:35.210+07:00</atom:updated><title>Demo using CollectionBase (Set - Get fields in Struct or Object)</title><description>&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Windows.Forms;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; WindowsApplication5
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Form1 : Form
    {
        Collection collection1 = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Collection();
        Collection collection2 = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Collection();

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; Form1()
        {
            InitializeComponent();
        }

        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; TurnIn_Click_1(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            &lt;span class=&quot;rem&quot;&gt;// them vao collection&lt;/span&gt;
            collection1.Add(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;.Parse(txtAge.Text), txtName.Text);
            lblStatus.Text = &lt;span class=&quot;str&quot;&gt;&quot;Test &quot;&lt;/span&gt; + txtAge.Text + &lt;span class=&quot;str&quot;&gt;&quot; added.&quot;&lt;/span&gt;;
        }

        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; LookAt_Click_1(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt; FirstCheck = collection2.Count() == 0;
            &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt; bThoat = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;

            &lt;span class=&quot;kwrd&quot;&gt;while&lt;/span&gt; (collection1.Count() &amp;gt; 0 &amp;amp;&amp;amp; !bThoat)
            {
                &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; x = collection1.Count() - 1;
                &lt;span class=&quot;rem&quot;&gt;// copy phan tu cuoi cung cua collection1 thanh phan tu dau tien cua collection2&lt;/span&gt;
                collection2.Insert(collection1.GetID(x), collection1.GetName(x), 0);

                &lt;span class=&quot;rem&quot;&gt;// xoa phan tu cuoi cung cua collection1&lt;/span&gt;
                collection1.RemoveAt(x);

                &lt;span class=&quot;rem&quot;&gt;// kiem tra phan tu nay co la bai test dang tim&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (collection2.GetID(0) == &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;.Parse(txtAge.Text))
                {
                    MessageBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;Student Name is: &quot;&lt;/span&gt; + collection2.GetName(0));
                    bThoat = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
                }
            }

            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!bThoat) &lt;span class=&quot;rem&quot;&gt;// neu khong tim thay bai test nao&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (FirstCheck)
                    MessageBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;Test not found.&quot;&lt;/span&gt;);
                &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;
                    MessageBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;Please click RETURN A TEST button to reset this result.&quot;&lt;/span&gt;);
        }        

        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Return_Click_1(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            &lt;span class=&quot;rem&quot;&gt;// chuyen tat ca phan tu cua collection2 vao lai collection1&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;while&lt;/span&gt; (collection2.Count() &amp;gt; 0)
            {
                collection1.Add(collection2.GetID(0), collection2.GetName(0));
                collection2.RemoveAt(0);
            }
        }     
    }

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Collection : CollectionBase
    {
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;struct&lt;/span&gt; TuTao
        {
            &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Age;
            &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Name;
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Add(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Age, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Name)
        {
            TuTao temp = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; TuTao();
            temp.Age = Age;
            temp.Name = Name;
            InnerList.Add(temp);
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; RemoveAt(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Vitri)
        {
            InnerList.RemoveAt(Vitri);
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Insert(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Age, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Name, &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Vitri)
        {
            TuTao temp = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; TuTao();
            temp.Age = Age;
            temp.Name = Name;
            InnerList.Insert(Vitri, temp);
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Count()
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; InnerList.Count;
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; GetName(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Vitri)
        {
            TuTao temp = (TuTao)InnerList[Vitri];
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; temp.Name;
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; GetID(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Vitri)
        {
            TuTao temp = (TuTao)InnerList[Vitri];
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; temp.Age;
        }
    }        
}
&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;hr&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;Demo 2

&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; CTDL_Chap01_Ex4
{
    &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Program
    {
        &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Main(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;[] args)
        {
            SinhVien A = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SinhVien();
            A.Add(&lt;span class=&quot;str&quot;&gt;&quot;Le Thanh Dat&quot;&lt;/span&gt;);
            A.Add(&lt;span class=&quot;str&quot;&gt;&quot;Vo Thuy Lien Tinh&quot;&lt;/span&gt;);
            A.Add(&lt;span class=&quot;str&quot;&gt;&quot;Nguyen Thi My Hanh&quot;&lt;/span&gt;);

            SinhVien B = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SinhVien();
            B.Add(&lt;span class=&quot;str&quot;&gt;&quot;http://www.vnxsoft.com&quot;&lt;/span&gt;);
            B.Add(&lt;span class=&quot;str&quot;&gt;&quot;http://www.microsoft.com&quot;&lt;/span&gt;);

            Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Truoc khi swap:&quot;&lt;/span&gt;);
            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; A.Count(); i++)
                Console.WriteLine(A.GetName(i));
            Console.WriteLine();
            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; B.Count(); i++)
                Console.WriteLine(B.GetName(i));

            Swap&amp;lt;SinhVien&amp;gt;(&lt;span class=&quot;kwrd&quot;&gt;ref&lt;/span&gt; A, &lt;span class=&quot;kwrd&quot;&gt;ref&lt;/span&gt; B);

            Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;\r\n\r\nSau khi swap:&quot;&lt;/span&gt;);
            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; A.Count(); i++)
                Console.WriteLine(A.GetName(i));
            Console.WriteLine();
            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; B.Count(); i++)
                Console.WriteLine(B.GetName(i));

            Console.ReadLine();
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Swap&amp;lt;T&amp;gt;(&lt;span class=&quot;kwrd&quot;&gt;ref&lt;/span&gt; T v1, &lt;span class=&quot;kwrd&quot;&gt;ref&lt;/span&gt; T v2)
        {
            T temp = (T)v1;
            v1 = v2;
            v2 = temp;
        }
    }

    &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; SinhVien : CollectionBase
    {
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Add(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; item)
        {
            InnerList.Add(item);
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; GetName(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Vitri)
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; InnerList[Vitri].ToString();
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Count()
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; InnerList.Count;
        }
    }
}&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/demo-using-collectionbase-set-get.html</link><author>noreply@blogger.com (Truong Duc Tai)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-7063990733318360127</guid><pubDate>Sun, 13 May 2012 22:05:00 +0000</pubDate><atom:updated>2012-05-14T05:05:33.312+07:00</atom:updated><title>How to Post data in C# . NET HttpWebRequest</title><description>&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.IO;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Net;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; ConsoleApplication1
{
    &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Class1
    {
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Post(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; url, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; postData)
        {
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; vystup = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
            {
                &lt;span class=&quot;rem&quot;&gt;//Our postvars&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;byte&lt;/span&gt;[] buffer = Encoding.ASCII.GetBytes(postData);
                &lt;span class=&quot;rem&quot;&gt;//Initialisation, we use localhost, change if appliable&lt;/span&gt;
                HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url);
                &lt;span class=&quot;rem&quot;&gt;//Our method is post, otherwise the buffer (postvars) would be useless&lt;/span&gt;
                WebReq.Method = &lt;span class=&quot;str&quot;&gt;&quot;POST&quot;&lt;/span&gt;;
                &lt;span class=&quot;rem&quot;&gt;//We use form contentType, for the postvars.&lt;/span&gt;
                WebReq.ContentType = &lt;span class=&quot;str&quot;&gt;&quot;application/x-www-form-urlencoded&quot;&lt;/span&gt;;
                &lt;span class=&quot;rem&quot;&gt;//The length of the buffer (postvars) is used as contentlength.&lt;/span&gt;
                WebReq.ContentLength = buffer.Length;
                &lt;span class=&quot;rem&quot;&gt;//We open a stream for writing the postvars&lt;/span&gt;
                Stream PostData = WebReq.GetRequestStream();
                &lt;span class=&quot;rem&quot;&gt;//Now we write, and afterwards, we close. Closing is always important!&lt;/span&gt;
                PostData.Write(buffer, 0, buffer.Length);
                PostData.Close();
                &lt;span class=&quot;rem&quot;&gt;//Get the response handle, we have no true response yet!&lt;/span&gt;
                HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
                &lt;span class=&quot;rem&quot;&gt;//Let&#39;s show some information about the response&lt;/span&gt;
                Console.WriteLine(WebResp.StatusCode);
                Console.WriteLine(WebResp.Server);

                &lt;span class=&quot;rem&quot;&gt;//Now, we read the response (the string), and output it.&lt;/span&gt;
                Stream Answer = WebResp.GetResponseStream();
                StreamReader _Answer = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; StreamReader(Answer);
                vystup = _Answer.ReadToEnd();

                &lt;span class=&quot;rem&quot;&gt;//Congratulations, you just requested your first POST page, you&lt;/span&gt;
                &lt;span class=&quot;rem&quot;&gt;//can now start logging into most login forms, with your application&lt;/span&gt;
                &lt;span class=&quot;rem&quot;&gt;//Or other examples.&lt;/span&gt;
            }
            &lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (Exception ex)
            {
                Console.Write(ex.Message);
            }
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; vystup.Trim() + &lt;span class=&quot;str&quot;&gt;&quot;\n&quot;&lt;/span&gt;;

        }
    }
}&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;hr&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; ConsoleApplication1
{
    &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Program
    {
        &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Main(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;[] args)
        {
            Class1 cls1 = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Class1();
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; sResponse = cls1.Post(&lt;span class=&quot;str&quot;&gt;@&quot;http://test.webjet.com.au/webjettsatrial/unauth.aspx&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;@&quot;PFPageID=FlightFinderTab&amp;amp;PFLayoutID=Layout&amp;amp;__EVENTTARGET=&amp;amp;__EVENTARGUMENT=&amp;amp;__LASTFOCUS=&amp;amp;__VIEWSTATE=%2FwEPDwUJNjEyNDMwODIwD2QWAgIBD2QWAgIJD2QWAmYPZBYCZg9kFgICBw9kFgJmD2QWEmYPDxYCHgdWaXNpYmxlaGQWAmYPZBYCZg9kFgICAw8PFgIeBFRleHQFAjMwZGQCAQ8PFgIfAGhkZAIEDxYCHwBoZAIGDw8WAh8AaGRkAgkPDxYCHwBoZGQCCg8PFgIfAGhkFgQCAQ8PFgIfAGhkZAIFDxYCHwEFDDEzMDAgMTM3IDczN2QCDA8WAh8AaGQCDQ8WAh8AaGQCDg8WAh8AaGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFhkFKENvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkVG9wTmF2JGltZ1dlYk1haWwFJUNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkVG9wTmF2JEltZ0xvZ28FRkNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkRmxpZ2h0RmluZGVyVGFiJG1udVN1Yk5hdmlnYXRpb25Vc2MkaW1nTGVmdE1lbnUFVUNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkRmxpZ2h0RmluZGVyVGFiJEhvbWVwYWdlVGFicyRGbGlnaHRzVGFiJHBubFRyaXBUeXBlJFRyaXBUeXBlIzAFVUNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkRmxpZ2h0RmluZGVyVGFiJEhvbWVwYWdlVGFicyRGbGlnaHRzVGFiJHBubFRyaXBUeXBlJFRyaXBUeXBlIzEFVUNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkRmxpZ2h0RmluZGVyVGFiJEhvbWVwYWdlVGFicyRGbGlnaHRzVGFiJHBubFRyaXBUeXBlJFRyaXBUeXBlIzEFVUNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkRmxpZ2h0RmluZGVyVGFiJEhvbWVwYWdlVGFicyRGbGlnaHRzVGFiJHBubFRyaXBUeXBlJFRyaXBUeXBlIzIFVUNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkRmxpZ2h0RmluZGVyVGFiJEhvbWVwYWdlVGFicyRGbGlnaHRzVGFiJHBubFRyaXBUeXBlJFRyaXBUeXBlIzIFWkNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkRmxpZ2h0RmluZGVyVGFiJEhvbWVwYWdlVGFicyRGbGlnaHRzVGFiJGN0bERlc3RpbmF0aW9uRmluZGVyX2ZpbmRlcgVgQ29udGVudFZpZXckUGFnZUxheW91dCRGbGlnaHRGaW5kZXJUYWIkSG9tZXBhZ2VUYWJzJEZsaWdodHNUYWIkY3RsRGVzdGluYXRpb25GaW5kZXJfZmluZGVyQm90dG9tBUhDb250ZW50VmlldyRQYWdlTGF5b3V0JEZsaWdodEZpbmRlclRhYiRIb21lcGFnZVRhYnMkRmxpZ2h0c1RhYiRidG5TZWFyY2gFUUNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkRmxpZ2h0RmluZGVyVGFiJEhvbWVwYWdlVGFicyRDYXJzVGFiMSRjdGxQaWNrdXBDaXR5X2ZpbmRlcgVXQ29udGVudFZpZXckUGFnZUxheW91dCRGbGlnaHRGaW5kZXJUYWIkSG9tZXBhZ2VUYWJzJENhcnNUYWIxJGN0bFBpY2t1cENpdHlfZmluZGVyQm90dG9tBUxDb250ZW50VmlldyRQYWdlTGF5b3V0JEZsaWdodEZpbmRlclRhYiRIb21lcGFnZVRhYnMkQ2Fyc1RhYjEkY2JsQ2FyVmVuZG9ycyQwBUxDb250ZW50VmlldyRQYWdlTGF5b3V0JEZsaWdodEZpbmRlclRhYiRIb21lcGFnZVRhYnMkQ2Fyc1RhYjEkY2JsQ2FyVmVuZG9ycyQxBUxDb250ZW50VmlldyRQYWdlTGF5b3V0JEZsaWdodEZpbmRlclRhYiRIb21lcGFnZVRhYnMkQ2Fyc1RhYjEkY2JsQ2FyVmVuZG9ycyQyBUxDb250ZW50VmlldyRQYWdlTGF5b3V0JEZsaWdodEZpbmRlclRhYiRIb21lcGFnZVRhYnMkQ2Fyc1RhYjEkY2JsQ2FyVmVuZG9ycyQzBUxDb250ZW50VmlldyRQYWdlTGF5b3V0JEZsaWdodEZpbmRlclRhYiRIb21lcGFnZVRhYnMkQ2Fyc1RhYjEkY2JsQ2FyVmVuZG9ycyQ0BUxDb250ZW50VmlldyRQYWdlTGF5b3V0JEZsaWdodEZpbmRlclRhYiRIb21lcGFnZVRhYnMkQ2Fyc1RhYjEkY2JsQ2FyVmVuZG9ycyQ0BUZDb250ZW50VmlldyRQYWdlTGF5b3V0JEZsaWdodEZpbmRlclRhYiRIb21lcGFnZVRhYnMkQ2Fyc1RhYjEkYnRuU2VhcmNoBUhDb250ZW50VmlldyRQYWdlTGF5b3V0JEZsaWdodEZpbmRlclRhYiRIb21lcGFnZVRhYnMkSG90ZWxzVGFiMSRidG5TZWFyY2gFOkNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkRmxpZ2h0RmluZGVyVGFiJGJ0blNlYXJjaE1hdHJpeERvd24FMkNvbnRlbnRWaWV3JFBhZ2VMYXlvdXQkQm90dG9tTmF2JGJ0blByb2ZpbGVEZXRhaWxzBSlDb250ZW50VmlldyRQYWdlTGF5b3V0JEJvdHRvbU5hdiRidG5Mb2dvbgUpQ29udGVudFZpZXckUGFnZUxheW91dCRSaWdodE5hdiRidG5NeVRyaXAHB4SN%2BrUIjKsA31wzEsFFOrcfag%3D%3D&amp;amp;__PREVIOUSPAGE=oyjS_uJrr0APVQWbsJUmfEUfPFMytN5uT70VAkQkkzA1&amp;amp;TSAServerName=&amp;amp;TSALastClientIP=&amp;amp;mail=Enter+your+email+address&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24pnlTripType%24TripType=Return&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlDeparting=SYD&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlDestinationFinder_city=London+Area+Airports&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlDestinationFinder_cityCode=&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlTravelClass=ECONOMY&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlDepartureDate_day=10&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlDepartureDate_month=2010%2F09&amp;amp;ctlDepartureDate_selectedYear=2010&amp;amp;ctlDepartureDate_selectedMonth=9&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlReturnDate_day=20&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlReturnDate_month=2010%2F09&amp;amp;ctlReturnDate_selectedYear=2010&amp;amp;ctlReturnDate_selectedMonth=9&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlAirline1=0&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24ctlAirline2Hidden=0&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24uscNumberOfPassengers%24ctlAdults=1&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24uscNumberOfPassengers%24ctlChildren=0&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24uscNumberOfPassengers%24ctlInfants=0&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24SearchTodayTime=18&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlPickupCity_city=&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlPickupCity_cityCode=&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlPickupDate_day=3&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlPickupDate_month=2010%2F08&amp;amp;ctlPickupDate_selectedYear=2010&amp;amp;ctlPickupDate_selectedMonth=8&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlPickupTime=%3F&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlPickupLocation=NotSpecified&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlDropoffDate_day=4&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlDropoffDate_month=2010%2F08&amp;amp;ctlDropoffDate_selectedYear=2010&amp;amp;ctlDropoffDate_selectedMonth=8&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlDropoffTime=%3F&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlDropoffLocation=NotSpecified&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24ctlCarSize=Any&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24cblCarVendors%240=on&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24cblCarVendors%241=on&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24cblCarVendors%242=on&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24cblCarVendors%243=on&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24CarsTab1%24cblCarVendors%244=on&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24HotelDestination%24Countries=AU&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24HotelDestination%24Destinations=451&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24HotelDestination%24Locations=&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24HotelDestination%24CascadingDropDown1_ClientState=AU%3A%3A%3AAustralia&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24HotelDestination%24ccdCountryDestination_ClientState=451%3A%3A%3ASydney&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24HotelDestination%24ccdDestinationLocation_ClientState=%3A%3A%3A&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24ctlCheckInDate_day=2&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24ctlCheckInDate_month=2010%2F08&amp;amp;ctlCheckInDate_selectedYear=2010&amp;amp;ctlCheckInDate_selectedMonth=8&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24ctlCheckOutDate_day=3&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24ctlCheckOutDate_month=2010%2F08&amp;amp;ctlCheckOutDate_selectedYear=2010&amp;amp;ctlCheckOutDate_selectedMonth=8&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24ctlNumberOfAdults=1&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24ctlNumberOfChildren=0&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24HotelsTab1%24rblResultsViewMode=List&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24currentView=SEARCH&amp;amp;Question=&amp;amp;QuestionLOH=&amp;amp;hiddenInputToUpdateATBuffer_CommonToolkitScripts=0&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24btnSearch.x=0&amp;amp;ContentView%24PageLayout%24FlightFinderTab%24HomepageTabs%24FlightsTab%24btnSearch.y=0&quot;&lt;/span&gt;);

            Console.WriteLine(sResponse);
            Console.ReadLine();
        }
    }
}&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;hr&gt;
Lưu ý để lấy dữ liệu từ Post dạng string dùng tool: Fiddler Web Debugger(v2.2.9.1) , &lt;br&gt;sau đó truyền string đó vào phương thức Post trong Class1 -&amp;gt; public string Post(string url, string postData)  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/how-to-post-data-in-c-net.html</link><author>noreply@blogger.com (Truong Duc Tai)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-3281438860563398090</guid><pubDate>Sun, 13 May 2012 21:59:00 +0000</pubDate><atom:updated>2012-05-14T04:59:24.324+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">T-SQL</category><title>Index trong MS SQL SERVER</title><description>&lt;p&gt;Nonclustered khác Clustered ở chỗ trong 1 table có lượng dữ liệu lớn với hàng ngàn, hàng triệu record thì khi tạo Clustered Index nó sẽ sắp xếp dữ liệu giúp chúng ta truy xuất nhanh hơn. Còn Nonclustered thì ko. Trong 1 table bạn chỉ có thể tạo 1 Clustered và nhiều Nonclustered, cho nên khi bạn tạo table và xác định PK thì PK đó được mặc định là Clustered. Vì thế khi bạn tạo thêm 1 Clustered Index cho table đó thì nó sẽ báo lỗi.&lt;/p&gt; &lt;p&gt;&lt;br&gt;Index, hay &quot;chỉ mục&quot; thực chất là một dạng tương tự như phần mục lục của một cuốn sách hay của một cuốn từ điễn vậy, các giá trị trong bảng được sắp theo cột, như vậy với suy nghĩ trên thì nếu cột nào được sắp index thì các giá trị trong cột đó sẽ được sắp xếp trong một cấu trúc bảng trong theo một trật tự dựa vào dữ liệu của bảng đó, việc làm này chủ yếu là giúp cho việc truy xuất trở nên nhanh hơn. Điều này tương tự như khi bạn tra từ điễn, thử tưởng tượng khi từ điễn không sắp xếp các từ theo thứ tự như: A---&amp;gt;AA---&amp;gt;AB.... thì bạn sẽ mất bao lâu để tra một từ &lt;/p&gt; &lt;p&gt;.&lt;br&gt;Trong SQL, index đóng vai trò là &lt;b&gt;tăng tốc truy xuất&lt;/b&gt;, do truy xuất cũng giống như khi bạn tra từ điễn, HT cần tìm kiếm thông tin trong hàng ngàn dữ liệu nên việc sắp xếp là cần thiết, mặt khác, do việc sắp xếp các dữ liệu là duy nhất (như trong từ điễn không thể có hai từ như nhau vì như vậy rất khó sắp xếp) nên có thể cho rằng index cũng &lt;b&gt;tăng tính duy nhất&lt;/b&gt; trong CSDL. Và cuỗi cùng, như đã biết các câu lệnh &lt;b&gt;JOIN, ORDER BY, GROUP BY&lt;/b&gt;cũng yêu cầu việc truy xuất dữ liệu liên tục nên index đồng thời cũng tăng tốc cho việc này.&lt;br&gt;Nghe có vẽ Index thật hữu dụng, nhưng khoan, index cũng có nhược điểm, cụ thể là để có index, bạn cần tạo nó, mà việc này rất &lt;b&gt;tốn thời gian&lt;/b&gt;, đối với các project mà chúng ta làm thì chả thấy gì, nhưng nếu đó là một CSDL lớn thì việc này là cực kì lâu. Thứ hai, do index là tạo một cấu trúc bảng trong nên việc này gây &lt;b&gt;tốn tài nguyên&lt;/b&gt; (nếu ai có cài google search desktop sẽ biết điều này). Và cuối cùng, do index là sắp xếp các dữ liệu nên &lt;b&gt;nếu có sự thay đổi thì index cũng được update theo&lt;/b&gt;.&lt;/p&gt; &lt;p&gt;&lt;br&gt;&lt;u&gt;&lt;font size=&quot;4&quot;&gt;Index trong CSDL có hai loại&lt;/font&gt;&lt;/u&gt;: &lt;b&gt;Clustered Index&lt;/b&gt; và &lt;b&gt;Non-Clustered Index&lt;/b&gt;.&lt;/p&gt; &lt;p&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Clustered index:&lt;/u&gt;&lt;/b&gt; thường được tự tạo ra khi bảng có primary key do primary key đã duy trì độ duy nhất dữ liệu của cột, nên có thể nói clustered index chính là unique index. Trong clustered index, các dữ liệu ở cấu trúc bảng trong được sắp xếp một cách vật lý, tức là trong clustered index, dữ liệu bảng trong được sắp xếp đúng theo thư mục cây dựa vào bảng chữ cái. Cách làm việc của index là dựa trên &lt;b&gt;ROOT PAGE&lt;/b&gt;, khi cần truy xuất, HT sẽ tìm đến địa chỉ cần tìm trong bảng &lt;b&gt;SYSINDEXES&lt;/b&gt;. Ví dụ như trong Root page có hai cột, một cột chứa dữ liệu trong cột index cột còn lại chứa tham chiếu số trang(dòng) trong bảng, cột index có giá trị là A (tham chiếu trang bảng trong là 1) và D(tham chiếu trang bảng trong là 2), (việc này do index quyết định), bạn cần tìm &quot;C&quot;, như vậy theo hệ chữ cái, HT sẽ biết rằng là C trong khoảng giữa A và D, HT từ đó dò đến trang bảng trong thứ 1 (tức chứa kí tự A, B, C .như vậy tương tự trang 2 sẽ là D,E,F...). Trong trang thứ 1, HT tiếp tục dò tìm kí tự C, lúc này kí tự C tham chiếu trang bảng thật là dòng 3 chẳng hạn. từ đó, HT lại lần đến trang bảng thật dòng 3 và dữ liệu được truy xuất (quá trình trên có thể tiếp tục nếu dữ liệu nhiều). trong một bảng &lt;b&gt;CHỈ&lt;/b&gt; được có duy nhất một clustered index&lt;br&gt;&lt;u&gt;&lt;b&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;b&gt;Non-Clustered Index:&lt;/b&gt;&lt;/u&gt; khác với clustered Index, non-Clustered Index không sắp xếp dữ liệu theo một trật tự vật lý như clustered mà là &quot;loạn xà ngầu&quot; trong bảng thông tin, miễn sao nó nằm trong một logic do index qui định :D. trong một bảng có thể chứa đến 249 non-clustered index. còn cách hoạt động thì tương tự clustered index, có khác là khi truy xuất đến bảng thông tin cuối thì thông tin không được sắp xếp theo trật tự thôi ví dụ như A---&amp;gt;C----&amp;gt;B-----&amp;gt;E----&amp;gt;D.....&lt;br&gt;một bảng không có index gọi là &lt;b&gt;HEAP&lt;/b&gt;.&lt;br&gt;mặc định thì primary key là clustered index còn foreign key là non-clustered index, do đó non-clustered index mặc định không đẩy mạnh tính duy nhất dữ liệu.&lt;br&gt;trong thực hành, để xác định clustered index, thường thì đó là primary key, nếu bảng có khóa composite thì index tự tạo cho cột khóa nào có dữ liệu dễ sắp xếp hơn. Nói chung thì clustered index thường không cần ta can thiệp, riêng non-clustered index thì khác, trước hết cần biết CSDL dùng để làm gì, từ đó xác định dữ liệu cột nào thường dùng để tìm kiếm trong các querry. Ở đây chủ yếu là các cột trong câu lệnh điều WHERE, ORDER BY, GROUP BY, hay các foreign key trong querry yêu cầu JOIN thì bạn có thể yên tâm &quot;phán&quot; cho nó cái non-clustered index rồi :D&lt;/p&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/index-trong-ms-sql-server.html</link><author>noreply@blogger.com (Truong Duc Tai)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-6705088154729952574</guid><pubDate>Sun, 13 May 2012 21:56:00 +0000</pubDate><atom:updated>2012-05-14T04:56:12.975+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><title>Advance .NET – Demo Serializable</title><description>&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Drawing;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.ComponentModel;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Windows.Forms;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Data;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Runtime.Serialization;&lt;span class=&quot;rem&quot;&gt;// Phải references &quot;System.Runtime.Serialization.Formatters.Soap.DLL&quot; nhé&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Runtime.Serialization.Formatters;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Runtime.Serialization.Formatters.Binary;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Runtime.Serialization.Formatters.Soap;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.IO;


&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; Demo_Serializable_Cho_CongPt
{
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// Summary description for Form1.&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Form1 : System.Windows.Forms.Form
    {        
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; btnXML_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, System.EventArgs e) &lt;span class=&quot;rem&quot;&gt;//Ghi File dang XML&lt;/span&gt;
        {
            &lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
            {
                &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; id = &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;.Parse(txtSinhvienID.Text.Trim());
                &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; name = txtTenSV.Text.Trim();
                &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; diachi = txtDC.Text.Trim();

                Sinhvien s = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Sinhvien(id, name, diachi);

                SoapFormatter soapF = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SoapFormatter();&lt;span class=&quot;rem&quot;&gt;// Dạng mã hóa dữ liệu XML&lt;/span&gt;
                Stream stream = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; FileStream(&lt;span class=&quot;str&quot;&gt;@&quot;C:\Temp\sinhvien_XML.DAT&quot;&lt;/span&gt;, FileMode.OpenOrCreate, FileAccess.Write);

                soapF.Serialize(stream, s);
                stream.Close();

            }
            &lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt;(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            MessageBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;Đã ghi dữ liệu dạng XML vào file: \&quot;sinhvien_XML.DAT\&quot;&quot;&lt;/span&gt;);

            txtSinhvienID.Text = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
            txtTenSV.Text = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
            txtDC.Text = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;

        }

        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; btnExit_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, System.EventArgs e)
        {
            Application.Exit();
        }

        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; button2_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, System.EventArgs e) &lt;span class=&quot;rem&quot;&gt;//Ghi File dang Ma Hoa&lt;/span&gt;
        {
            &lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
            {
                &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; id = &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;.Parse(txtSinhvienID.Text.Trim());
                &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; name = txtTenSV.Text.Trim();
                &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; diachi = txtDC.Text.Trim();

                Sinhvien s = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Sinhvien(id, name, diachi);

                BinaryFormatter binary = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; BinaryFormatter();&lt;span class=&quot;rem&quot;&gt;//Dạng mã hóa dữ liệu nhị phân&lt;/span&gt;
                Stream stream = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; FileStream(&lt;span class=&quot;str&quot;&gt;@&quot;C:\Temp\sinhvien_MaHoa.DAT&quot;&lt;/span&gt;, FileMode.OpenOrCreate, FileAccess.Write);

                binary.Serialize(stream, s);
                stream.Close();

            }
            &lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt;(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            MessageBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;Đã ghi dữ liệu dạng mã hóa nhị phân vào file: \&quot;sinhvien_MaHoa.DAT\&quot;&quot;&lt;/span&gt;);

            txtSinhvienID.Text = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
            txtTenSV.Text = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
            txtDC.Text = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
        }

        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; btnReadXML_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, System.EventArgs e)
        {
            SoapFormatter formatter = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SoapFormatter();&lt;span class=&quot;rem&quot;&gt;// Ghi file dạng gì thì dùng dạng ấy để đọc mới được&lt;/span&gt;
            Stream stream = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; FileStream(&lt;span class=&quot;str&quot;&gt;@&quot;C:\Temp\sinhvien_XML.DAT&quot;&lt;/span&gt;, FileMode.Open, FileAccess.Read);

            Sinhvien s = (Sinhvien)formatter.Deserialize(stream); &lt;span class=&quot;rem&quot;&gt;// Dịch ngược file--Tức đọc file&lt;/span&gt;
            stream.Close();

            txtSinhvienID.Text = s.ID.ToString();
            txtTenSV.Text = s.Name;
            txtDC.Text = s.Diachi;
        }

        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; button1_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, System.EventArgs e)
        {
            BinaryFormatter formatter = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; BinaryFormatter();&lt;span class=&quot;rem&quot;&gt;// Ghi file dạng gì thì dùng dạng ấy để đọc mới được&lt;/span&gt;
            Stream stream = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; FileStream(&lt;span class=&quot;str&quot;&gt;@&quot;C:\Temp\sinhvien_MaHoa.DAT&quot;&lt;/span&gt;, FileMode.Open, FileAccess.Read);

            Sinhvien s = (Sinhvien)formatter.Deserialize(stream); &lt;span class=&quot;rem&quot;&gt;// Dịch ngược file--Tức đọc file&lt;/span&gt;
            stream.Close();

            txtSinhvienID.Text = s.ID.ToString();
            txtTenSV.Text = s.Name;
            txtDC.Text = s.Diachi;
        }
    }
}&lt;hr&gt;&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Windows.Forms;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; Demo_Serializable_Cho_CongPt
{
    [Serializable] &lt;span class=&quot;rem&quot;&gt;//Cái này hiểu là class đựợc gọi là để ghi và đọc file theo 2 cách XML và Nhị phân&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Sinhvien
    {
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; id;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; name;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; diachi;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; Sinhvien(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; id, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; name, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; diachi)
        {
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.id = id;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.name = name;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.diachi = diachi;
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; ID
        {
            get
            {
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; id;
            }
        }
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Name
        {
            get
            {
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; name;
            }
            set
            {
                name = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;;
            }
        }
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Diachi
        {
            get
            {
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; diachi;
            }
            set
            {
                diachi = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;;
            }
        }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; HienthiThongtin()
        {
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; info = &lt;span class=&quot;str&quot;&gt;&quot;Thong tin Sinh Vien: \n&quot;&lt;/span&gt;;
            info += &lt;span class=&quot;str&quot;&gt;&quot;ID la: &quot;&lt;/span&gt;+id+&lt;span class=&quot;str&quot;&gt;&quot;\n&quot;&lt;/span&gt;;
            info += &lt;span class=&quot;str&quot;&gt;&quot;Ten la la: &quot;&lt;/span&gt;+name+&lt;span class=&quot;str&quot;&gt;&quot;\n&quot;&lt;/span&gt;;
            info += &lt;span class=&quot;str&quot;&gt;&quot;Dia chi la: &quot;&lt;/span&gt;+diachi;

            MessageBox.Show(info);
        }
    }
}&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/advance-net-demo-serializable.html</link><author>noreply@blogger.com (Truong Duc Tai)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-6753265727077841118</guid><pubDate>Sun, 13 May 2012 21:36:00 +0000</pubDate><atom:updated>2012-05-14T04:36:21.499+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">T-SQL</category><title>Triggers And Views</title><description>&lt;p&gt;Trong bài này chúng ta sẽ tìm hiểu ứng dụng của một loại stored procedure đặc biệt gọi là Triggers và dùng Views để thể hiện data trong một hay nhiều table như thế nào.  &lt;p&gt;&lt;strong&gt;Triggers&lt;/strong&gt;  &lt;p&gt;Trigger là một loại stored procedure đặc biệt được execute (thực thi) một cách tự động khi có một data modification event xảy ra như Update, Insert hay Delete. Trigger được dùng để đảm bảo Data Integrity hay thực hiện các business rules nào đó.  &lt;p&gt;&lt;strong&gt;Khi nào ta cần sử dụng Trigger:&lt;/strong&gt;  &lt;ul&gt; &lt;li&gt;Ta chỉ sử dụng trigger khi mà các biện pháp bảo đảm data intergrity khác như Constraints không thể thỏa mãn yêu cầu của ứng dụng. Nên nhớ Constraint thuộc loại Declarative Data Integrity cho nên sẽ kiểm tra data trước khi cho phép nhập vào table trong khi Trigger thuộc loại Procedural Data Integrity nên việc insert, update, delete đã xảy ra rồi mới kích hoạt trigger. Chính vì vậy mà ta cần cân nhắc trước khi quyết định dùng loại nào trong việc đảm bảo Data Integrity.  &lt;li&gt;Khi một database được denormalized (ngược lại quá trình normalization, là một quá trình thiết kế database schema sao cho database chứa data không thừa không thiếu) sẽ có một số data thừa (redundant ) được chứa trong nhiều tables. Nghĩa là sẽ có một số data được chứa cùng một lúc ở hai hay nhiều nơi khác nhau. Khi đó để đảm bảo tính chính xác thì khi data được update ở một table này thì cũng phải được update một cách tự động ở các table còn lại bằng cách dùng Trigger.&lt;br&gt;Ví dụ: ta có table Item trong đó có field Barcode dùng để xác định một mặt hàng nào đó. Item table có vai trò như một cuốn catalog chứa những thông tin cần thiết mô tả từng mặt hàng. Ta có một table khác là Stock dùng để phản ánh món hàng có thực trong kho như được nhập về này nào được cung cấp bởi đại lý nào, số lượng bao nhiêu (tức là những thông tin về món hàng mà không thể chứa trong Item table được)...table này cũng có field Barcode để xác định món hàng trong kho. Như vậy thông tin về Barcode được chứa ở hai nơi khác nhau do đó ta cần dùng trigger để đảm bảo là Barcode ở hai nơi luôn được synchonize (đồng bộ).  &lt;li&gt;Ðôi khi ta có nhu cầu thay đổi dây chuyền (cascade) ta có thể dùng Trigger để bảo đảm chuyện đó. Nghĩa là khi có sự thay đổi nào đó ở table này thì một số table khác cũng được thay đổi theo để đảm bảo tính chính xác. Ví dụ như khi một món hàng được bán đi thì số lượng hàng trong table Item giảm đi một món đồng thời tổng số hàng trong kho (Stock table) cũng phải giảm theo một cách tự động. Như vậy ta có thể tạo một trigger trên Item table để mỗi khi một món được bán đi thì trigger sẽ được kích hoạt và giảm tổng số hàng trong Stock table.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Ðặc điểm của Trigger:&lt;/strong&gt;  &lt;ul&gt; &lt;li&gt;Một trigger có thể làm nhiều công việc (actions) khác nhau và có thể được kích hoạt bởi nhiều hơn một event. Ví dụ ta có thể viết một trigger được kích hoạt bởi bất kỳ event nào như Update, Insert hay Delete và bên trong trigger ta sẽ viết code để giải quyết cho từng trường hợp.  &lt;li&gt;Trigger không thể được tạo ra trên temporary hay system table.  &lt;li&gt;Trigger chỉ có thể được kích hoạt một cách tự động bởi một trong các event Insert, Update, Delete mà không thể chạy manually được.  &lt;li&gt;Có thể áp dụng trigger cho View.  &lt;li&gt;Khi một trigger được kích hoạt thì data mới vừa được insert hay mới vừa được thay đổi sẽ được chứa trong Inserted table còn data mới vừa được delete được chứa trong Deleted table. Ðây là 2 table tạm chỉ chứa trên memory và chỉ có giá trị bên trong trigger mà thôi (nghĩa là chỉ nhìn thấy và được query trong trigger mà thôi). Ta có thể dùng thông tin trong 2 table này để so sánh data cũ và mới hoặc kiểm tra xem data mới vừa thay đổi có hợp lệ trước khi commit hay roll back. (Xem thêm ví dụ bên dưới)  &lt;li&gt;Có 2 loại triggers (class) : INSTEAD OF và AFTER. Loại INSTEAD OF sẽ bỏ qua (bybass) action đã kích hoạt trigger mà thay vào đó sẽ thực hiện các dòng lệnh SQL bên trong Trigger. Ví dụ ta có một Update trigger trên một table với câu INSTEAD OF thì khi table được update thay vì update SQL Server sẽ thực hiện các lệnh đã được viết sẵn bên trong trigger. Ngược lại loại AFTER (loại default tương đương với keyword FOR) sẽ thực hiện các câu lệnh bên trong trigger sau khi các action tạo nên trigger đã xảy ra rồi.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Tạo Một Trigger Như Thế Nào?&lt;/strong&gt;  &lt;p&gt;Cú pháp căn bản để tạo ra một trigger có dạng như sau:  &lt;blockquote&gt; &lt;p&gt;&lt;strong&gt;CREATE TRIGGER&lt;/strong&gt; trigger_name&lt;br&gt;&lt;strong&gt;ON&lt;/strong&gt; table_name or view_name&lt;br&gt;&lt;strong&gt;FOR&lt;/strong&gt; trigger_class and trigger_type(s)&lt;br&gt;&lt;strong&gt;AS&lt;/strong&gt; Transact-SQL statements&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Như vậy khi tạo ra một trigger ta phải chỉ rõ là tạo ra trigger trên table nào và được trigger khi nào (insert, update hay delete. Sau chữ AS là các câu lệnh SQL xử lý công việc.  &lt;p&gt;Ta hãy nghiên cứu một ứng dụng thực tiễn sau. Giả sử ta viết một application cho phép user có thể Insert, Update và Delete những thông tin nằm trong database. User này thường là những người không thông thạo lắm về computer mà chúng tôi thường gọi đùa là &quot;bà tám&quot;. Vào một ngày đẹp trời, &quot;bà tám&quot; mặt mày tái xanh đến cầu cứu ta vì đã lỡ tay &quot;delete&quot; những thông tin khá quan trọng và hy vọng ta có thể phục hồi dữ liệu dùm. Nếu chúng ta không phòng xa trước khi viết application thì coi như cũng vô phương cứu chữa vì data đã hoàn toàn bị delete.&lt;br&gt;Nhưng nếu bạn là một &quot;guru&quot; bạn sẽ gật gù &quot;chuyện này khó lắm!&quot; nhưng sau đó bạn chỉ tốn vài phút đồng hồ để rollback. Muốn làm được chuyện này chúng ta phải dùng một &quot;chiêu&quot; gọi là Audit (kiểm tra hay giám sát). Tức là ngoài các table chính ta sẽ thêm các table phụ gọi là Audit tables. Bất kỳ hoạt động nào đụng chạm vào một số table quan trọng trong database ta đều ghi nhận vào trong Audit table. Ví dụ khi user update hay delete một record trong table nào đó thì trước khi update hay delete ta sẽ âm thầm di chuyển record đó sang Audit table rồi mới update hay delete table chính. Như vậy nếu có chuyện gì xảy ra ta có thể dễ dàng rollback (trả record về chỗ cũ).  &lt;p&gt;&lt;strong&gt;Ví dụ: &lt;/strong&gt; &lt;p&gt;Ta có table Orders trong PracticeDB. Ðể audit các hoạt động diễn ra trên table này ta tạo ra một audit table với tên Aud_Orders với các column giống y hệt với Orders table. Ngoài ra ta thêm vào 2 columns:&amp;nbsp; &lt;ul&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Audit_Type : với các giá trị có thể là &#39;I&#39;,&#39;U&#39;,&#39;D&#39; để ghi nhận record được Insert, Update hay Delete  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date_Time_Stamp : Data Type thuộc loại DateTime dùng để ghi nhận thời điểm xảy ra sự thay đổi, có vai trò như một con dấu.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;(Nếu trong môi trường nhiều user thì ta thêm một column UserID để ghi nhận user nào thay đổi).  &lt;p&gt;Sau đó ta sẽ tạo ra 3 trigger dùng cho việc audit&amp;nbsp; như sau:&lt;pre&gt;	--Insert Trigger&lt;br&gt;	CREATE TRIGGER [AuditInsertOrders] &lt;br&gt;	ON [dbo].[Orders] &lt;br&gt;	FOR Insert &lt;br&gt;	AS&lt;br&gt;	insert into aud_orders select *,&#39;I&#39;,getdate() From inserted&lt;/pre&gt;&lt;pre&gt;	--Update Trigger&lt;br&gt;	CREATE TRIGGER [AuditUpdateOrders] &lt;br&gt;	ON [dbo].[Orders] &lt;br&gt;	for UPDATE &lt;br&gt;	AS&lt;br&gt;	insert into aud_orders select *,&#39;U&#39;,Getdate() from deleted &lt;br&gt;&lt;br&gt;	--Delete Trigger&lt;br&gt;	CREATE TRIGGER [AuditDeleteOrders] &lt;br&gt;	ON [dbo].[Orders] &lt;br&gt;	FOR DELETE &lt;br&gt;	AS&lt;br&gt;	insert into aud_orders select *,&#39;D&#39;,getdate() From deleted&lt;/pre&gt;
&lt;p&gt;Trong ví dụ trên khi user insert một record thì record mới vừa được insert sẽ nằm trong inserted table như đã trình bày ở phần trên. Do đó ta sẽ select tất cả các column trong inserted table cộng thêm Audit Type &quot;I&quot; và dùng hàm GetDate() trong SQL Server để lấy system date time dùng cho Date_Time_Stamp column, sau đó insert vào Aud_Orders table. Tương tự với trường hợp Update và Delete, record đã được update hay delete nằm trong deleted table.&amp;nbsp; &lt;p&gt;Như vậy trở lại trường hợp thí dụ ở trên nếu &quot;bà tám&quot; yêu cầu ta có thể vào tìm kiếm trong audit table để phục hồi lại record. Ngoài ra ta có thể dùng table này để tìm ra thủ phạm đã xoá hay sửa chữa data khi cần thiết.&amp;nbsp; &lt;p&gt;Ðể tạo ra hay xem một trigger bằng Enterprise Manager bạn làm như sau: Right-Click lên table mà bạn muốn tạo trigger-&amp;gt;All Tasks-&amp;gt; Manage Triggers.&amp;nbsp; &lt;p&gt;Lưu ý: Ðôi Khi ta chỉ muốn trigger thực sự hoạt động khi một hay vài column nào đó được Update chứ không phải bất kỳ column nào. Khi đó ta có thể dùng hàm Update(Column_Name) để kiểm tra xem column nào đó có bị update hay không.&amp;nbsp; &lt;p&gt;&lt;strong&gt;Ví dụ:&lt;/strong&gt; 
&lt;p&gt;Tạo một trigger cho Customer table. Bên trong Trigger (sau chữ AS) ta có thể kiểm tra xem nếu column First_Name hay Last_Name bị thay đổi thì mới hành động nếu không thì không làm gì cả&lt;pre&gt;	IF UPDATE (first_name) OR UPDATE (Last_Name)&lt;br&gt;	BEGIN&lt;br&gt;		Do some conditional processing when either of these columns are updated.&lt;br&gt;	END&lt;/pre&gt;
&lt;p&gt;Nếu muốn kiểm tra nhiều columns ta có thể dùng hàm khác là Columns_Updated() . Xin xem thêm trong SQL Server Books Online để biết thêm chi tiết về cách sử dụng. 
&lt;p&gt;&lt;strong&gt;Views&lt;/strong&gt; 
&lt;p&gt;Ðịnh nghĩa một cách đơn giản thì view trong SQL Server tương tự như Query trong Access database. View có thể được xem như một table ảo mà data của nó được select từ một stored query. Ðối với programmer thì view không khác chi so với table và có thể đặt ở vị trí của table trong các câu lệnh SQL. Ðặc điểm của View là ta có thể join data từ nhiều table và trả về một recordset đơn. Ngoài ra ta có thể &quot;xào nấu&quot; data (manipulate data) trước khi trả về cho user bằng cách dùng một số logic checking như (if, case...). 
&lt;p&gt;&lt;strong&gt;Ví dụ:&lt;/strong&gt;&lt;pre&gt;	Create View OrderReport&lt;br&gt;	As	&lt;br&gt;	Select OrderID,&lt;br&gt;	       (case when [Name] is null then &#39;New Customer&#39;&lt;br&gt;		else [Name]&lt;br&gt;		end )As CustomerName,&lt;br&gt;		ProductName,&lt;br&gt;		DateProcessed&lt;br&gt;	From Customers Right Outer Join Orders on Customers.CustomerID=Orders.CustomerID&lt;/pre&gt;
&lt;p&gt;Trong ví dụ trên ta chủ yếu trả về data từ Orders table trong PracticeDB nhưng thay vì display CustomerID vốn không có ý nhiều ý nghĩa đối với user ta sẽ display tên của customer bằng cách join với Customer table. Nếu Customer Name là Null nghĩa là tên của customer đã đặt order không tồn tại trong system. Thay vì để Null ta sẽ display &quot;New Customer&quot; để dễ nhìn hơn cho user. 
&lt;p&gt;Nói chung câu lệnh SQL trong View có thể từ rất đơn giản như select toàn bộ data từ một table cho đến rất phức tạp với nhiều tính năng programming của T-SQL. 
&lt;p&gt;&lt;strong&gt;View Thường Ðược Dùng Vào Việc Gì?&lt;/strong&gt; 
&lt;p&gt;View thường được sử dùng vào một số công việc sau: 
&lt;ul&gt;
&lt;li&gt;Tập trung vào một số data nhất định : ta thường dùng view để select một số data mà user quan tâm hay chịu trách nhiệm và loại bỏ những data không cần thiết.&lt;br&gt;Ví dụ: Giả sử trong table ta có column &quot;Deleted&quot; với giá trị là True hay False để đánh dấu một record bị delete hay không. Việc này đôi khi được dùng cho việc Audit. Nghĩa là trong một ứng dụng nào đó khi user delete một record nào đó, thay vì ta physically delete record ta chỉ logically delete bằng cách đánh dấu record là đã được &quot;Deleted&quot; để đề phòng user yêu cầu roll back. Như vậy chủ yếu ta chỉ quan tâm đến data chưa delete còn data đã được đánh dấu deleted chỉ được để ý khi nào cần roll back hay audit mà thôi. Trong trường hợp này ta có thể tạo ra một view select data mà Deleted=False và làm việc chủ yếu trên view thay vì toàn bộ table. 
&lt;li&gt;Ðơn giản hóa việc xử lý data: Ðôi khi ta có những query rất phức tạp và sử dụng thường xuyên ta có thể chuyển nó thành View và đối xử nó như một table, như vậy sẽ làm cho việc xử lý data dễ dàng hơn. 
&lt;li&gt;Customize data: Ta có thể dùng view để làm cho users thấy data từ những góc độ khác nhau mặc dù họ đang dùng một nguồn data giống nhau. Ví dụ: Ta có thể tạo ra views trong đó những thông tin về customer được thể hiện khác nhau tùy login ID là normal user hay manager. 
&lt;li&gt;Export và Import data: Ðôi khi ta muốn export data từ SQL Server sang các ứng dụng khác như Excel chẳng hạn ta có thể dùng view để join nhiều table và export dùng bcp.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Khi sử dụng view ta có thể select,insert, update, delete data bình thường như với một table. 
&lt;p&gt;&lt;strong&gt;Ví dụ:&lt;/strong&gt;&lt;pre&gt;	Select * From OrderReport&lt;br&gt;	Where DateProcessed &amp;lt;&#39;2003-01-01&#39;&lt;br&gt;&lt;/pre&gt;
&lt;p&gt;Gửi bởi: ngocdv&lt;/p&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/triggers-and-views.html</link><author>noreply@blogger.com (Truong Duc Tai)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-8671948181604498229</guid><pubDate>Fri, 11 May 2012 15:29:00 +0000</pubDate><atom:updated>2012-05-11T22:32:33.188+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Remove nested tag form with jQuery</title><description>&lt;p&gt;Code before use jQuery&lt;/p&gt; &lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;aspnetForm&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;post&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;#&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;aspnetForm&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;       &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;jQuery, Asp.net, Java&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;      some text             &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;post&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;#&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;form1&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;love4all1080.blogspot.com&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;free-style-love.blogspot.com&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;solake.net&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;                &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;  some text&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;code c#&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;    &lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;


&lt;p&gt;result to this&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;aspnetForm&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;post&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;#&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;aspnetForm&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;jQuery, Asp.net, Java&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;            some text             &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;                 &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;love4all1080.blogspot.com&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;free-style-love.blogspot.com&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;solake.net&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;                    &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;                 &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;            some text&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;code c#&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;    &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt;        &lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;jQuery code&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;$(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; foo = $(&lt;span class=&quot;str&quot;&gt;&quot;#form1&quot;&lt;/span&gt;).contents()&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;    $(&lt;span class=&quot;str&quot;&gt;&quot;#form1&quot;&lt;/span&gt;).replaceWith(foo);&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;});&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;or short code&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;$(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;     $(&lt;span class=&quot;str&quot;&gt;&#39;#form1 &amp;gt; *&#39;&lt;/span&gt;).unwrap();&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;}); &lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-rollingonthefloorlaughing&quot; alt=&quot;Rolling on the floor laughing&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWiAaEXnZhyphenhyphen8OFbd3N-d4-1P8ImahpKlG9QkBY-YUMh0IJoN6_4hmvQZ2iLzawbGwbDGKtoHMHA8wM6cqOsgMhmGxJId3jIiZH9DIWp8HpqxOlq7BXi2n2-zCP4rmjhCRWdY-hVy5ksw/?imgmax=800&quot;&gt;&lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-punch&quot; alt=&quot;Punch&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg609nMpg5-DuNFjZGT5RttfcvtFa3q2mZwnRclx36C66P9P-UE60rEyVsvY1pf7eUoo0LSxdZnnishxQCOAw6z0N7TfFuZ3O9YXLIydmVMyLZsBqmAMbu5lNoBmOdIjufjDUciSZc0Gw/?imgmax=800&quot;&gt;&lt;/p&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/remove-nested-tag-form-with-jquery.html</link><author>noreply@blogger.com (Johnson William)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWiAaEXnZhyphenhyphen8OFbd3N-d4-1P8ImahpKlG9QkBY-YUMh0IJoN6_4hmvQZ2iLzawbGwbDGKtoHMHA8wM6cqOsgMhmGxJId3jIiZH9DIWp8HpqxOlq7BXi2n2-zCP4rmjhCRWdY-hVy5ksw/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-2333082753343446336</guid><pubDate>Fri, 11 May 2012 03:47:00 +0000</pubDate><atom:updated>2012-05-11T10:47:56.886+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><category domain="http://www.blogger.com/atom/ns#">Plugin jQuery</category><title>JQUERY SHOWLOADING PLUGIN</title><description>&lt;p&gt;I found on the internet when trying to search keyword ‘Show loading’ and see a nice plugin jQuery. This plugin is designed to show a loading graphic over a specific area of the screen (e.g. a specific &amp;lt;div&amp;gt;) while an ajax request is running.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://www.contextllc.com/dev_tools/jQuery/showLoading/latest/jquery.showLoading.example.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;View Demo&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Example script:&lt;/p&gt; &lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;jQuery(document).ready(&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;       &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;// When a user clicks the &#39;loading-default&#39; link,&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;// call showLoading on the activity pane&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;// with default options&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;         jQuery(&lt;span class=&quot;str&quot;&gt;&#39;a.loading-default&#39;&lt;/span&gt;).click(&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;           &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;               jQuery(&lt;span class=&quot;str&quot;&gt;&#39;#activity_pane&#39;&lt;/span&gt;).showLoading();&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;           }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  15:  &lt;/span&gt;         );&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  16:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  17:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  18:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;// When a user clicks the &#39;loading-ajax&#39; link,&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  19:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;// call showLoading before performing the &#39;load&#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  20:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  21:  &lt;/span&gt;         jQuery(&lt;span class=&quot;str&quot;&gt;&#39;a.load-ajax&#39;&lt;/span&gt;).click(&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  22:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  23:  &lt;/span&gt;           &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  24:  &lt;/span&gt;               jQuery(&lt;span class=&quot;str&quot;&gt;&#39;#activity_pane&#39;&lt;/span&gt;).showLoading();&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  25:  &lt;/span&gt;               jQuery(&lt;span class=&quot;str&quot;&gt;&#39;#activity_pane&#39;&lt;/span&gt;).load( &lt;span class=&quot;str&quot;&gt;&#39;/some/url&#39;&lt;/span&gt;,&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  26:  &lt;/span&gt;                    &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  27:  &lt;/span&gt;                          &lt;span class=&quot;rem&quot;&gt;// callback fires after ajax load completes&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  28:  &lt;/span&gt;                          jQuery(&lt;span class=&quot;str&quot;&gt;&#39;#activity_pane&#39;&lt;/span&gt;).hideLoading();&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  29:  &lt;/span&gt;                   }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  30:  &lt;/span&gt;               );&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  31:  &lt;/span&gt;           }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  32:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  33:  &lt;/span&gt;         );&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  34:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  35:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  36:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;// When a user clicks the &#39;loading-bars&#39; link,&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  37:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;// call showLoading with addClass specified&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  38:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  39:  &lt;/span&gt;         jQuery(&lt;span class=&quot;str&quot;&gt;&#39;a.loading-bars&#39;&lt;/span&gt;).click(&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  40:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  41:  &lt;/span&gt;           &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  42:  &lt;/span&gt;               jQuery(&lt;span class=&quot;str&quot;&gt;&#39;#activity_pane&#39;&lt;/span&gt;).showLoading(&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  43:  &lt;/span&gt;                 {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  44:  &lt;/span&gt;                   &lt;span class=&quot;str&quot;&gt;&#39;addClass&#39;&lt;/span&gt;: &lt;span class=&quot;str&quot;&gt;&#39;loading-indicator-bars&#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  45:  &lt;/span&gt;                                              }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  46:  &lt;/span&gt;               );&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  47:  &lt;/span&gt;           }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  48:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  49:  &lt;/span&gt;         );&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  50:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  51:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  52:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;// When a user clicks the &#39;loading-hide&#39; link,&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  53:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;// call hideLoading on the activity pane&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  54:  &lt;/span&gt;         &lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  55:  &lt;/span&gt;         jQuery(&lt;span class=&quot;str&quot;&gt;&#39;a.loading-hide&#39;&lt;/span&gt;).click(&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  56:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  57:  &lt;/span&gt;           &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  58:  &lt;/span&gt;               jQuery(&lt;span class=&quot;str&quot;&gt;&#39;#activity_pane&#39;&lt;/span&gt;).hideLoading();&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  59:  &lt;/span&gt;           }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  60:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  61:  &lt;/span&gt;         );&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  62:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  63:  &lt;/span&gt;       }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  64:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  65:  &lt;/span&gt;   );&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Css Style:&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;.loading-indicator {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;    height: 80px;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;    width: 80px;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;    background: url( &#39;../images/loading.gif&#39; );&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;    background-repeat: no-repeat;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;    background-position: center center;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;.loading-indicator-overlay {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;    background-color: #FFFFFF;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;    opacity: 0.6;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;    filter: alpha(opacity = 60);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;js Source:&lt;/p&gt;
&lt;p&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;a href=&quot;https://sites.google.com/site/love4all1080/js/jquery.showLoading.js?attredirects=0&amp;amp;d=1&quot; target=&quot;_blank&quot;&gt;jquery.showLoading&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How to use:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text/javascript&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;     $(&lt;span class=&quot;str&quot;&gt;&#39;#info1 a&#39;&lt;/span&gt;).click(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; ($(&lt;span class=&quot;str&quot;&gt;&quot;#form1&quot;&lt;/span&gt;).valid())&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;            $(&lt;span class=&quot;str&quot;&gt;&quot;#info1&quot;&lt;/span&gt;).showLoading();&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;            $.post(url,{id: &lt;span class=&quot;str&quot;&gt;&#39;Johnson&#39;&lt;/span&gt;}, &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;(d,s){&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (d.status){&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;                    &lt;span class=&quot;rem&quot;&gt;//do something&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;                }&lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;{&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;                    show_message_dialog(d.data);&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;                }&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;                $(&lt;span class=&quot;str&quot;&gt;&quot;#info1&quot;&lt;/span&gt;).hideLoading();&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt;            }, &lt;span class=&quot;str&quot;&gt;&#39;json&#39;&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  15:  &lt;/span&gt;        }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  16:  &lt;/span&gt;        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  17:  &lt;/span&gt;    });&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  18:  &lt;/span&gt;    &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  19:  &lt;/span&gt;    &lt;span class=&quot;rem&quot;&gt;//the same with #info2,  #info3&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  20:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  21:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  22:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  23:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;info1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;position: relative&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  24:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;#&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  25:  &lt;/span&gt;    &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- form data submit.. --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  26:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  27:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;info2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;position: relative&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  28:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;#&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  29:  &lt;/span&gt;    &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- form data submit.. --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  30:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  31:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;info3&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;position: relative&quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  32:  &lt;/span&gt;    &amp;amp;&lt;span class=&quot;attr&quot;&gt;lt&lt;/span&gt;;&lt;span class=&quot;attr&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;#&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  33:  &lt;/span&gt;    &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- form data submit.. --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  34:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;Can be add more style loading use:&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;jQuery(&lt;span class=&quot;str&quot;&gt;&#39;#activity_pane&#39;&lt;/span&gt;).showLoading(&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt; {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;       &lt;span class=&quot;str&quot;&gt;&#39;addClass&#39;&lt;/span&gt;: &lt;span class=&quot;str&quot;&gt;&#39;loading-indicator-bars&#39;&lt;/span&gt;                                &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;


&lt;p&gt;css style&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;.loading-indicator-bars {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;        background-image: url(&lt;span class=&quot;str&quot;&gt;&#39;images/loading-bars.gif&#39;&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;        width: 150px;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;    }&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/jquery-showloading-plugin.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-4747998303458869089</guid><pubDate>Tue, 08 May 2012 16:08:00 +0000</pubDate><atom:updated>2012-05-08T23:08:59.607+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Jquery get ID in ASP.NET</title><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;blockquote style=&quot;margin-right: 0px&quot; dir=&quot;ltr&quot;&gt; &lt;p&gt;$(&#39;[id$=timePicker]&#39;).timepicker();&lt;/p&gt;&lt;/blockquote&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/jquery-get-id-in-aspnet.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-4880580749515237459</guid><pubDate>Tue, 08 May 2012 15:51:00 +0000</pubDate><atom:updated>2012-05-08T22:51:17.770+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Show Your IP by JSON JQuery</title><description>&lt;p&gt;Function javascript:&lt;/p&gt; &lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; ShowMyIP() {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; url = &lt;span class=&quot;str&quot;&gt;&quot;http://jsonip.appspot.com?callback=?&quot;&lt;/span&gt;;     &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;    $.getJSON(url, &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;(data) {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;        &lt;span class=&quot;rem&quot;&gt;//show client IP from url&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;        $(&lt;span class=&quot;str&quot;&gt;&#39;#ip_location&#39;&lt;/span&gt;).html(&lt;span class=&quot;str&quot;&gt;&quot;Your Ip Location:&quot;&lt;/span&gt; + data.ip);         &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;    });&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Html:&lt;/p&gt;
&lt;p&gt;&amp;lt;div id=”ip_location”&amp;gt;&amp;lt;/div&amp;gt;&lt;/p&gt;
&lt;p&gt;JQuery call function&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;$(document).ready(function() {    &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;    ShowMyIP();   &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;});&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/show-your-ip-by-json-jquery.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-7717439030913101271</guid><pubDate>Tue, 08 May 2012 13:49:00 +0000</pubDate><atom:updated>2012-05-08T20:49:18.865+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Get Location by using Jquery</title><description>&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;jQuery.getScript(&lt;span class=&quot;str&quot;&gt;&#39;http://www.geoplugin.net/javascript.gp&#39;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;    $(&lt;span class=&quot;str&quot;&gt;&#39;#getScript-results&#39;&lt;/span&gt;).html(&lt;span class=&quot;str&quot;&gt;&quot;Your location is: &quot;&lt;/span&gt; + geoplugin_countryName() + &lt;span class=&quot;str&quot;&gt;&quot;,&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;    &quot;&lt;/span&gt; + geoplugin_region() + &lt;span class=&quot;str&quot;&gt;&quot;, &quot;&lt;/span&gt; + geoplugin_city());&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;});&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Data Json result&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;blockquote&gt;&lt;pre&gt;function geoplugin_request() { return &#39;117.5.192.65&#39;;} 
function geoplugin_status() { return &#39;200&#39;;} 
function geoplugin_city() { return &#39;Hanoi&#39;;} 
function geoplugin_region() { return &#39;Ha Nội&#39;;} 
function geoplugin_regionCode() { return &#39;44&#39;;} 
function geoplugin_regionName() { return &#39;Ha Nội&#39;;} 
function geoplugin_areaCode() { return &#39;0&#39;;} 
function geoplugin_dmaCode() { return &#39;0&#39;;} 
function geoplugin_countryCode() { return &#39;VN&#39;;} 
function geoplugin_countryName() { return &#39;Vietnam&#39;;} 
function geoplugin_continentCode() { return &#39;AS&#39;;} 
function geoplugin_latitude() { return &#39;21.033300&#39;;} 
function geoplugin_longitude() { return &#39;105.849998&#39;;} 
function geoplugin_currencyCode() { return &#39;VND&#39;;} 
function geoplugin_currencySymbol() { return &#39;&amp;amp;#8363;&#39;;} 
function geoplugin_currencyConverter(amt, symbol) { 
	if (!amt) { return false; } 
	var converted = amt * 20810; 
	if (converted &amp;lt;0) { return false; } 
	if (symbol === false) { return Math.round(converted * 100)/100; } 
	else { return &#39;&amp;amp;#8363;&#39;+(Math.round(converted * 100)/100);} 
	return false; 
} &lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/get-location-by-using-jquery.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-1141714175564165711</guid><pubDate>Sun, 06 May 2012 16:45:00 +0000</pubDate><atom:updated>2012-05-06T23:45:26.703+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Formats for DateTime.ToString()</title><description>&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;DateTime dt = DateTime.Now;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;String strDate=&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;MM/dd/yyyy&quot;&lt;/span&gt;);   &lt;span class=&quot;rem&quot;&gt;// 07/21/2007 &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;dddd, dd MMMM yyyy&quot;&lt;/span&gt;);   &lt;span class=&quot;rem&quot;&gt;//Saturday, 21 July 2007&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;dddd, dd MMMM yyyy HH:mm&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// Saturday, 21 July 2007 14:58&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;dddd, dd MMMM yyyy hh:mm tt&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// Saturday, 21 July 2007 03:00 PM&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;dddd, dd MMMM yyyy H:mm&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// Saturday, 21 July 2007 5:01 &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;dddd, dd MMMM yyyy h:mm tt&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// Saturday, 21 July 2007 3:03 PM&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;dddd, dd MMMM yyyy HH:mm:ss&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// Saturday, 21 July 2007 15:04:10&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;MM/dd/yyyy HH:mm&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 07/21/2007 15:05&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;MM/dd/yyyy hh:mm tt&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 07/21/2007 03:06 PM&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;MM/dd/yyyy H:mm&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 07/21/2007 15:07&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;MM/dd/yyyy h:mm tt&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 07/21/2007 3:07 PM&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;MM/dd/yyyy HH:mm:ss&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 07/21/2007 15:09:29&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  15:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;MMMM dd&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// July 21&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  16:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;yyyy&#39;-&#39;MM&#39;-&#39;dd&#39;T&#39;HH&#39;:&#39;mm&#39;:&#39;ss.fffffffK&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 2007-07-21T15:11:19.1250000+05:30    &lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  17:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;ddd, dd MMM yyyy HH&#39;:&#39;mm&#39;:&#39;ss &#39;GMT&#39;&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// Sat, 21 Jul 2007 15:12:16 GMT&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  18:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;yyyy&#39;-&#39;MM&#39;-&#39;dd&#39;T&#39;HH&#39;:&#39;mm&#39;:&#39;ss&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 2007-07-21T15:12:57&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  19:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;HH:mm&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 15:14&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  20:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;hh:mm tt&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 03:14 PM&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  21:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;H:mm&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 5:15&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  22:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;h:mm tt&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 3:16 PM&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  23:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;HH:mm:ss&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 15:16:29&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  24:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;yyyy&#39;-&#39;MM&#39;-&#39;dd HH&#39;:&#39;mm&#39;:&#39;ss&#39;Z&#39;&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// 2007-07-21 15:17:20Z&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  25:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;dddd, dd MMMM yyyy HH:mm:ss&quot;&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;// Saturday, 21 July 2007 15:17:58&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  26:  &lt;/span&gt;strDate = dt.ToString(&lt;span class=&quot;str&quot;&gt;&quot;yyyy MMMM&quot;&lt;/span&gt;); // 2007 July&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/formats-for-datetimetostring.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-14777607361869275.post-3225427201188616167</guid><pubDate>Fri, 04 May 2012 05:33:00 +0000</pubDate><atom:updated>2012-05-04T12:33:01.884+07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Replace multiple spaces in a string with special characters</title><description>&lt;p&gt;The original string:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;What are&amp;nbsp;&amp;nbsp; you looking&amp;nbsp;&amp;nbsp;&amp;nbsp; for ?&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;After using code:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;what-are-you-looking-for?&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Code Demo:&lt;/p&gt; &lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;       &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Main(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;        {                        &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; keyword = &lt;span class=&quot;str&quot;&gt;&quot;What are   you   looking for ?&quot;&lt;/span&gt;;            &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; abc = RegexReplaceMultiSpace(keyword).ToLower();            &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;            Console.WriteLine();&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;        }&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; RegexReplaceMultiSpace(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; input)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; space = &lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; character = &lt;span class=&quot;str&quot;&gt;&quot;-&quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; result = Regex.Replace(input, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;[{0}]+&quot;&lt;/span&gt;, space), character);             &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;            result = result.Remove(result.LastIndexOf(character),1);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;        }&lt;/pre&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright (c) by Love4all1080&lt;/div&gt;</description><link>http://cool-develop.blogspot.com/2012/05/replace-multiple-spaces-in-string-with.html</link><author>noreply@blogger.com (Johnson William)</author><thr:total>0</thr:total></item></channel></rss>