<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" 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" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CE8NQH4_fSp7ImA9WhBaFU0.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356</id><updated>2013-05-25T22:58:11.045+05:30</updated><category term="wcf" /><category term="jQuery dropdown" /><category term="jQuery" /><category term="jQuery mouse events" /><category term="blogspot tricks" /><category term="Javascript" /><category term="C# Strings" /><category term="DateTime CSharp" /><category term="C# DateTime" /><category term="blogger tricks" /><category term="jQuery click" /><category term="C#" /><category term="csharp" /><category term="jQuery dialog" /><category term="asp.net checkboxlist" /><category term="jQuery Checkbox" /><category term="C# list" /><category term="Linq" /><category term="validate email" /><category term="jQuery radio button" /><category term="asp.net" /><category term="asp.net gridview" /><category term="jQuery Ajax" /><category term="C# array" /><category term="jQuery validations" /><category term="asp.net checkbox" /><category term="json" /><title>C# | ASP.net | jQuery | Javascript | linq</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.codegateway.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://www.codegateway.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>109</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq" /><feedburner:info uri="makeiteasyaspnetcdotnetframeworkclrjqueryclientsidescriptinglinq" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;C0QAQH0-fip7ImA9WhBVGEQ.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-1873416779420417207</id><published>2013-04-25T17:32:00.000+05:30</published><updated>2013-04-25T17:32:21.356+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-25T17:32:21.356+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery dropdown" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>Set dropdown text selected from textbox value</title><content type="html">&lt;p&gt;In some cases we need to set dropdown list items exact text by matching the value entered in textbox. For that purpose we can use .keyup event in jQuery. In .keyup event simply take the value of textbox and assign that value to the value of dropdown. Once you set value it's corresponding text will be get displayed as selected.&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt;

&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&amp;gt;
&amp;lt;head id=&amp;quot;Head1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;
    &amp;lt;script src=&amp;quot;Scripts/jquery-1.4.1.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
     &amp;lt;script src=&amp;quot;Scripts/jquery-1.4.1.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;title&amp;gt;Get dropdown value&amp;lt;/title&amp;gt;
    &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
        $(document).ready(function () {
            $(&amp;quot;#topics&amp;quot;).keyup(function () {
                var value = $(&amp;quot;#topics&amp;quot;).val();
                if (value == &amp;quot;&amp;quot; || isNaN(value))
                    value = 0;
                $(&amp;quot;#topics1&amp;quot;).val(value);
            });
        });
    &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;
    &amp;lt;div&amp;gt;
    &amp;lt;asp:TextBox runat=&amp;quot;server&amp;quot; ID=&amp;quot;topics&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;
    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;
      &amp;lt;asp:DropDownList ID=&amp;quot;topics1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;
     &amp;lt;asp:ListItem Text=&amp;quot;--Select--&amp;quot; Value=&amp;quot;0&amp;quot;&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
    &amp;lt;asp:ListItem Text=&amp;quot;C#&amp;quot; Value=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
    &amp;lt;asp:ListItem Text=&amp;quot;jQuery&amp;quot; Value=&amp;quot;2&amp;quot;&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
    &amp;lt;asp:ListItem Text=&amp;quot;ASP.NET&amp;quot; Value=&amp;quot;3&amp;quot;&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
    &amp;lt;/asp:DropDownList&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;&lt;b&gt;
Note: You may need some additional validations if user enters data in textbox that does not match to the values in dropdown. Ex. I have just validated in above code if user enters characters other than number using IsNaN &lt;/b&gt;
&lt;/p&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/4zxI-nDNdB4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/1873416779420417207/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2013/04/set-dropdown-text-selected-from-textbox.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/1873416779420417207?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/1873416779420417207?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/4zxI-nDNdB4/set-dropdown-text-selected-from-textbox.html" title="Set dropdown text selected from textbox value" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2013/04/set-dropdown-text-selected-from-textbox.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMHRHo5eSp7ImA9WhBQEEU.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-4931338480056726477</id><published>2013-03-12T15:26:00.000+05:30</published><updated>2013-03-12T16:03:55.421+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-12T16:03:55.421+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery Ajax" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>jQuery templates</title><content type="html">&lt;p&gt;jQuery templates is a useful plugin developed by Microsofts's ASP.NET team in collaboration with jquery open source team. Templates helps you to manipulate the data at client side and display in browser. It is more useful to display the dataset that is fetched from database using client side Asynch Ajax call.&lt;/p&gt;
&lt;p&gt;
&lt;h1&gt; jQuery Template example &lt;/h1&gt;
In order to use jQuery templates we either need to download "jquery.tmpl.js" plugin and add reference or we can also refer it from cdn.
&lt;code&gt;&lt;pre&gt;
&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&amp;gt;
&amp;lt;head runat=&amp;quot;server&amp;quot;&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
     &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
     &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;

      $(document).ready(function () {
          debugger;
          var loc = window.location.href;
          $.ajax({
              type: &amp;#039;POST&amp;#039;,
              url: loc + &amp;quot;/GetBookList&amp;quot;,
              data: &amp;quot;{}&amp;quot;,
              contentType: &amp;quot;application/json; charset=utf-8&amp;quot;

          })
        .success(function (response) {
            debugger;
            $(&amp;quot;#bookCollection&amp;quot;).tmpl(response.d).appendTo(&amp;quot;.book-container&amp;quot;);
        })
        .error(function (response) {
            alert(response.d);
        });

      });
  &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;
    &amp;lt;div class=&amp;quot;book-container&amp;quot;&amp;gt;
    
    &amp;lt;/div&amp;gt;
     &amp;lt;script id=&amp;quot;bookCollection&amp;quot; type=&amp;quot;text/x-jQuery-tmpl&amp;quot;&amp;gt;
        &amp;lt;div&amp;gt;
           &amp;lt;h2&amp;gt;${Title}&amp;lt;/h2&amp;gt;
            Author: ${Author}
            price: ${Price}
        &amp;lt;/div&amp;gt;
    &amp;lt;/script&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;/code&gt;
Here in above code below script is template to which we are going to bind the data.
     &amp;lt;script id=&amp;quot;bookCollection&amp;quot; type=&amp;quot;text/x-jQuery-tmpl&amp;quot;&amp;gt;
        &amp;lt;div&amp;gt;
           &amp;lt;h2&amp;gt;${Title}&amp;lt;/h2&amp;gt;
            Author: ${Author}
            price: ${Price}
        &amp;lt;/div&amp;gt;
    &amp;lt;/script&amp;gt;

And by using  $(&amp;quot;#bookCollection&amp;quot;).tmpl(response.d).appendTo(&amp;quot;.book-container&amp;quot;); we actually bind the data to the template and append that template to some fixed html like div. 
&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;
Below code is for reference to get data from code behind method:
&lt;pre&gt;&lt;code&gt;
 [WebMethod]
        public static List&lt;Book&gt; GetBookList()
        {

            return new List&lt;Book&gt;()
                       {
                           new Book {Title = "ASP.NET", Author = "Stephen", Price = 350.9},
                           new Book {Title = "WPF", Author = "Murli", Price = 400},
                           new Book {Title = "WCF", Author = "Avinash", Price = 350}
                       };
        }
&lt;/pre&gt;&lt;/code&gt; 
Refer &lt;a href="http://www.codegateway.com/2012/05/jquery-call-page-codebehind-method.html"&gt;link&lt;/a&gt; to know how to make a ajax call to code behind. 
&lt;/p&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/puftUppgrNs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/4931338480056726477/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2013/03/jquery-templates.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/4931338480056726477?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/4931338480056726477?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/puftUppgrNs/jquery-templates.html" title="jQuery templates" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2013/03/jquery-templates.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkAFRXg6eCp7ImA9WhBQEEs.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-6330744784884817152</id><published>2013-03-12T10:33:00.001+05:30</published><updated>2013-03-12T10:35:14.610+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-12T10:35:14.610+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="csharp" /><title>Dynamic in C# 4.0</title><content type="html">&lt;p&gt;Dynamic type is introduced C# 4.0. As its name specifies type of the defined variable is decided dynamically at runtime. At compile time the variable that is declared as dynamic is assumed to be support any type or operation. As it does everything at runtime if code is not valid then errors are caught at runtime. Two major disadvantages of dynamic type are No compile time checking and No intelliSense support&lt;/p&gt;
&lt;p&gt;
&lt;h1&gt; Dynamic type example &lt;/h1&gt;

Suppose we have class called SomeClass that have methods Method1() and Sum(intx, int y).
&lt;code&gt;&lt;pre&gt;
    public class SomeClass
    {
        public SomeClass()
        {
        }

        public void Method1()
        {
            //Do something
        }

        public int Sum(int x, int y)
        {
            return x + y;
        }
    }
&lt;/pre&gt;&lt;/code&gt;
&lt;br /&gt;
and we are now trying to use the above class using dynamic type.
&lt;code&gt;&lt;pre&gt;
    public partial class DynamicType : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            dynamic someclass_dy = new SomeClass();
           
            someclass_dy.Method1();

            someclass_dy.Sum(10, 3);

            someclass_dy.SomeOtherMethod();
        }
     }
&lt;/pre&gt;&lt;/code&gt;
&lt;br /&gt;
In above code we have defined dynamic type object of class SomeClass(). and now if you try to access methods from that class it will not show any method in intelliSense, you explicitly need to know the class methods and call them that is because dynamic type does not supports compile time checking. If you notice there is code line someclass_dy.SomeOtherMethod(); where SomeOtherMethod() does not exists in SomeClass() still it will not throw any compile time error, but it will throw runtime error.

&lt;/p&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/2RluBiKYS6U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/6330744784884817152/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2013/03/dynamic-in-c-40.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6330744784884817152?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6330744784884817152?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/2RluBiKYS6U/dynamic-in-c-40.html" title="Dynamic in C# 4.0" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2013/03/dynamic-in-c-40.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcNQXo-fyp7ImA9WhBRGUU.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-2230682997584194442</id><published>2013-03-11T12:11:00.001+05:30</published><updated>2013-03-11T12:11:30.457+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-11T12:11:30.457+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="csharp" /><title>Tuple in C# 4.0</title><content type="html">&lt;p&gt;Tuple is a new class introduced in C# 4.0. Tuple basically provides way to group the items of different data types. A static Tuple class provides 8 overloads of create method to create Tuple of size 1 to 8. Also using new keyword and nesting tuples you can create more sized Tuple. Now for example tuple created with 3 elements called 3-tuple or triple that can hold three elements of any type. So first element may be firstname that is string, second element may be phone number that is int and salary which is double may be the third element. And we can read those values using item property of tuple like for 3-tuple it will tuple.Item1, tuple.Item2 and tuple.Item3.&lt;/p&gt;
&lt;p&gt;
&lt;h1&gt;Tuple example 3-tuple&lt;/h1&gt;
&lt;code&gt;&lt;pre&gt;
     var tuple3 = new Tuple&lt;string, int, double&gt;("Johan", 1234567890, 56000.90);
     Console.WriteLine(tuple3.Item1);
     Console.WriteLine(tuple3.Item2);
     Console.WriteLine(tuple3.Item3);
&lt;/pre&gt;&lt;/code&gt;
&lt;br /&gt; In above example it will print
&lt;samp&gt;
 &lt;pre&gt;&lt;b&gt;Output:&lt;/b&gt;
  Johan
  1234567890
  56000.90
&lt;/pre&gt;
&lt;/samp&gt;
&lt;br /&gt;
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/PL2DKGxH_pI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/2230682997584194442/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2013/03/tuple-in-c-40.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/2230682997584194442?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/2230682997584194442?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/PL2DKGxH_pI/tuple-in-c-40.html" title="Tuple in C# 4.0" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2013/03/tuple-in-c-40.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0QDRXYyfyp7ImA9WhBRGUU.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-6989970762734051275</id><published>2013-03-11T11:26:00.000+05:30</published><updated>2013-03-11T11:26:14.897+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-11T11:26:14.897+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="csharp" /><title>Lazy loading C#. Lazy initialization.</title><content type="html">&lt;p&gt;C# 4.0 introduced new class Lazy&lt;T&gt; which provided for Lazy initialization. Lazy instantiation here means object is not created until it is get used first time. Primary use of Lazy initialization is performance improvements, reduce program memory requirements.Lazy&lt;T&gt; provides thread safe object initialization. 
&lt;/p&gt;
&lt;p&gt;
&lt;h1&gt;Lasy&amp;lt;T&amp;gt; example to load object lazily&lt;/h1&gt;
&lt;code&gt;&lt;pre&gt;
public partial class LazyClass : System.Web.UI.Page 
{
 private Lazy&amp;lt;List&amp;lt;string&amp;gt;&amp;gt; lazyItems = null; 
 public LazyClass() 
 { 
   lazyItems = new Lazy&amp;lt;List&amp;lt;string&amp;gt;&amp;gt;(GetItems); 
 } 
 public List&amp;lt;string&amp;gt; GetItems() 
 {
      List&amp;lt;string&amp;gt; items = new List&amp;lt;string&amp;gt;(); 
      for (int i = 0; i &amp;lt; 10; i++) 
       { 
          items.Add(string.Format(&amp;quot;Item {0}&amp;quot;, i)); 
       } return items;
 }

 public List&amp;lt;string&amp;gt; GetItemValues { get { return lazyItems.Value; } } 
}
&lt;/pre&gt;&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;So in above example we have defined private Lazy&amp;lt;List&amp;lt;string&amp;gt;&amp;gt; lazyItems = null; and then in constructor we have delegate the call to GetItems method which will return list of items. But here it will not generate and return list until we call "lazyItems.Value".&lt;/p&gt;&lt;br/&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/ii3_-UbPZM0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/6989970762734051275/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2013/03/lazy-loading-c-lazy-initialization.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6989970762734051275?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6989970762734051275?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/ii3_-UbPZM0/lazy-loading-c-lazy-initialization.html" title="Lazy loading C#. Lazy initialization." /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2013/03/lazy-loading-c-lazy-initialization.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkUEQHk4fip7ImA9WhNUEk0.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-6546643179359333723</id><published>2012-11-18T13:43:00.000+05:30</published><updated>2013-01-03T13:33:21.736+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-03T13:33:21.736+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linq" /><title>Skip in Linq C#</title><content type="html">&lt;p&gt;Skip() in  Linq avoids or skips the given number of elements from the sequence.&lt;/p&gt;

&lt;p&gt;&lt;h2&gt;Skip() example in Linq&lt;/h2&gt;&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
  protected void Page_Load(object sender, EventArgs e)
        {
            var numArr = new int[5];
            numArr[0] = 9;
            numArr[1] = 6;
            numArr[2] = 3;
            numArr[3] = 5;
            numArr[4] = 2;

            var numbers = numArr.Skip(3);
            foreach (var number in numbers)
            {
                Console.WriteLine(number);
            }
&lt;/pre&gt;&lt;/code&gt;
&lt;samp&gt;
 &lt;pre&gt;// Output will be 5, 2&lt;/pre&gt;
&lt;/samp&gt;

&lt;p&gt;So in above example of skip in linq, we have numArr.Skip(3);, that will skip first three elements from array and print remaining array elements.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/oWNY3bScM-k" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/6546643179359333723/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/11/skip-in-linq-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6546643179359333723?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6546643179359333723?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/oWNY3bScM-k/skip-in-linq-c.html" title="Skip in Linq C#" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/11/skip-in-linq-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D04NQXkyfSp7ImA9WhNQEk8.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-8475257938073849164</id><published>2012-11-18T13:36:00.000+05:30</published><updated>2012-11-18T13:36:30.795+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-18T13:36:30.795+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linq" /><title>Take() in Linq C#</title><content type="html">&lt;p&gt;In Linq i.e. System.Linq, Take operator is used to get the first specified number of elements a sequence.&lt;/p&gt;

&lt;p&gt;&lt;h2&gt;Linq Take() example&lt;/h2&gt;&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;
using System.Linq;
protected void Page_Load(object sender, EventArgs e)
        {
            var numArray = new int[5];
            numArray[0] = 95;
            numArray[1] = 66;
            numArray[2] = 3;
            numArray[3] = 54;
            numArray[4] = 2;


            var numbers = numArray.Take(3);
            foreach (var number in numbers)
            {
                Console.WriteLine(number);
            }
        }
&lt;/pre&gt;&lt;/code&gt;
&lt;samp&gt;
 &lt;pre&gt;//It will print 95, 66, 3.&lt;/pre&gt;
&lt;/samp&gt;

&lt;p&gt;So in above sample code of Take() we have numArray.Take(3) that means it will return us the sequence of first three elements from array. &lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/y46l6MeMj7U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/8475257938073849164/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/11/take-in-linq-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8475257938073849164?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8475257938073849164?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/y46l6MeMj7U/take-in-linq-c.html" title="Take() in Linq C#" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/11/take-in-linq-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEMBRnk9fip7ImA9WhNQFU0.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-75401541417783747</id><published>2012-11-16T22:33:00.000+05:30</published><updated>2012-11-21T18:24:17.766+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-21T18:24:17.766+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linq" /><title>AsEnumerable() in Linq</title><content type="html">&lt;p&gt;AsEnumerable() method in Linq is used to cast or convert given type into it's IEnumerable type. AsEnumerable() basically  changes the compile time type of given type that implements IEnumerable&lt;T&gt; to IEnumerable&lt;T&gt; itself.&lt;/p&gt;

&lt;p&gt;&lt;h2&gt;Sample code to use AsEnumerable() in Linq&lt;/h2&gt;&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;
 protected void Page_Load(object sender, EventArgs e)
  {
      var numArray = new int[5];
      numArray[0] = 5;
      numArray[1] = 10;
      numArray[2] = 7;
      numArray[3] = 9;
      numArray[4] = 1;

      var numbers = numArray.AsEnumerable();
      foreach (var number in numbers)
       {
          Console.WriteLine(number);
       }
  }
&lt;/pre&gt;&lt;/code&gt;
&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/Pv8hJy-uRtI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/75401541417783747/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/11/asenumerable-in-linq.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/75401541417783747?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/75401541417783747?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/Pv8hJy-uRtI/asenumerable-in-linq.html" title="AsEnumerable() in Linq" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/11/asenumerable-in-linq.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUcMSHw7cSp7ImA9WhNRGE4.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-8116093938827802568</id><published>2012-11-14T00:30:00.000+05:30</published><updated>2012-11-14T01:34:49.209+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-14T01:34:49.209+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linq" /><title>Convert ToList() in Linq</title><content type="html">&lt;p&gt;In C# Linq, there is .ToList() extension method that is used to convert IEnumerable to List of type. Like .ToArray(), ToList() also forces immediate query execution and stores query result in List&lt;T&gt;.&lt;/p&gt;

&lt;p&gt;&lt;h2&gt;Example that shows how to convert array to list&lt;/h2&gt;&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;
 protected void Page_Load(object sender, EventArgs e)
  {
     string[] language = { "C#", "C++", "Java", "Pascal", "Cobol" };
     List&lt;string&gt; languageList = language.ToList();

     foreach (string lang in languageList)
     {
                Console.WriteLine(lang);
     }
  }
&lt;/pre&gt;&lt;/code&gt;
&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/OlOolGPyWq0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/8116093938827802568/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/11/convert-tolist-in-linq_14.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8116093938827802568?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8116093938827802568?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/OlOolGPyWq0/convert-tolist-in-linq_14.html" title="Convert ToList() in Linq" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/11/convert-tolist-in-linq_14.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEICRX8_eCp7ImA9WhNRFUo.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-2681656411597502378</id><published>2012-11-11T00:06:00.000+05:30</published><updated>2012-11-11T00:06:04.140+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-11T00:06:04.140+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linq" /><title>Convert ToArray in linq</title><content type="html">&lt;p&gt;In C# while using Linq, we have .ToArray() extension method that is used to convert IEnumerable to an array.  .ToArray() forces immediate query execution and stores query result in an array. &lt;/p&gt;

&lt;p&gt;&lt;h2&gt;Example of Linq .ToArray()&lt;/h2&gt;&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;
 public partial class LinqToArray : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            var carslist =
                new List&lt;Cars&gt; 
                        { new Cars { Company = "Maruti Suzuki", Average = 15.2 },
                          new Cars { Company = "Mercedes", Average = 18.7 },
                          new Cars { Company = "Volvo", Average = 20.0 },
                          new Cars { Company = "Hundai", Average = 12.8 } };

            var companies = carslist.Where(c =&gt; c.Average &gt; 15)
                                         .Select(c =&gt; c.Company)
                                         .ToArray();

            foreach (var company in companies)
            {
                Console.WriteLine(company);
            }
        }

    public class Cars
    {
        public string Company { get; set; }
        public double Average { get; set; }
    }

&lt;/pre&gt;&lt;/code&gt;
&lt;samp&gt;
 &lt;pre&gt;&lt;b&gt;Output:&lt;/b&gt;
   /*
     //Maruti Suzuki
     // Mercedes
     // Volvo
   */
&lt;/pre&gt;
&lt;/samp&gt;

&lt;p&gt;In above sample code we have converted List to array using linq.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/1gi11TDnXHU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/2681656411597502378/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/11/convert-toarray-in-linq.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/2681656411597502378?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/2681656411597502378?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/1gi11TDnXHU/convert-toarray-in-linq.html" title="Convert ToArray in linq" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/11/convert-toarray-in-linq.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0UFRH8-eip7ImA9WhNREEk.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-571663391368226465</id><published>2012-11-04T20:30:00.000+05:30</published><updated>2012-11-04T20:30:15.152+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T20:30:15.152+05:30</app:edited><title>ASP.NET CompareValidator</title><content type="html">&lt;p&gt;
In this post we will see how to use compare validator to compare the two input values. Using compare validator we can compare two values from two different input controls or we can compare input value with some constant or fixed value.
&lt;/p&gt;
&lt;p&gt;Example of compare validator&lt;/p&gt;
&lt;code&gt;
&lt;pre&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;
&amp;lt;head runat="server"&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;ul style="list-style-type: none"&amp;gt;
            &amp;lt;li&amp;gt;
                &amp;lt;asp:TextBox ID="txt1" runat="server" /&amp;gt;
                =
                &amp;lt;asp:TextBox ID="txt2" runat="server" /&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li&amp;gt;
                &amp;lt;asp:Button ID="Button1" Text="Validate" runat="server" /&amp;gt;
            &amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
        &amp;lt;br&amp;gt;
        &amp;lt;asp:CompareValidator ID="compareval" Display="dynamic" ControlToValidate="txt1"
            ControlToCompare="txt2" ForeColor="red" Type="String" EnableClientScript="false"
            Text="Values are not equal." runat="server" /&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;
So in compare validator we need to set ControlToValidate and ControlToCompare in order to compare two input values.
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/rWS9_auz0jY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/571663391368226465/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/11/aspnet-comparevalidator.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/571663391368226465?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/571663391368226465?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/rWS9_auz0jY/aspnet-comparevalidator.html" title="ASP.NET CompareValidator" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/11/aspnet-comparevalidator.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C08GQnw5eyp7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-6009808047109996119</id><published>2012-11-04T17:52:00.000+05:30</published><updated>2012-11-04T17:53:43.223+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T17:53:43.223+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="asp.net" /><title>RangeValidator to validate data in between |  asp.net</title><content type="html">&lt;p&gt;
From the set of validation server controlin asp.net  we will see how to use RangeValidator in this post.&lt;/p&gt;
&lt;p&gt;
RangeValidator is used to check if values entered are in between specific range or not. In order to use RangeValidator, we need to add server control &lt;asp:rangevalidator&gt;on web form.&lt;/asp:rangevalidator&gt;&lt;/p&gt;

&lt;p&gt;RangeValidator example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;
&amp;lt;head runat="server"&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;div&amp;gt;
        Enter a number between 0 and 5:
        &amp;lt;br&amp;gt;
        &amp;lt;asp:TextBox ID="txtNumber" runat="server" /&amp;gt;
        &amp;lt;asp:RangeValidator ID="RangeValidator1" ControlToValidate="txtNumber" MinimumValue="0"
            MaximumValue="5" Type="Integer" Text="The number should be in between 0 to 5."
            ForeColor="red" runat="server" /&amp;gt;
        &amp;lt;br&amp;gt;
        &amp;lt;asp:Button ID="Button1" Text="Submit" runat="server" /&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
In order to rangevalidator to be work we need to set few properties:
1. Minimum value&lt;br /&gt;
2. Maximum value&lt;br /&gt;
3. Control to validate&lt;br /&gt;
4. Type of data i.e. Interger, Date...etc.&lt;br /&gt;
5. And the Text for error message
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/Zp2_8lLWYdI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/6009808047109996119/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/11/rangevalidator-to-validate-data-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6009808047109996119?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6009808047109996119?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/Zp2_8lLWYdI/rangevalidator-to-validate-data-in.html" title="RangeValidator to validate data in between |  asp.net" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/11/rangevalidator-to-validate-data-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04HRHo4eSp7ImA9WhNSGEo.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-2387120567672677624</id><published>2012-11-02T23:39:00.000+05:30</published><updated>2012-11-02T23:42:15.431+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-02T23:42:15.431+05:30</app:edited><title>jQuery auto focus.</title><content type="html">&lt;p&gt;
In this post we will see how to set focus automatically on input control. This is done using .focus() function in jQuery.&lt;/p&gt;
&lt;p&gt;&lt;h2&gt;
jQuery auto focus example&lt;/h2&gt;&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;
&amp;lt;script type="text/javascript"&amp;gt;
&amp;nbsp;&amp;nbsp; $(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#fName").focus();
&amp;nbsp;&amp;nbsp; });
&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;/code&gt;
&lt;p&gt;
.focus()function is simple and we can call it on input control on which we need to set focus. &lt;/p&gt;
&lt;p&gt;
&lt;h3&gt;
Below is simple full example of .focus() in jQuery&lt;/h3&gt;
&amp;nbsp;&amp;lt;html xmlns="&lt;a href="http://www.w3.org/1999/xhtml"&gt;http://www.w3.org/1999/xhtml&lt;/a&gt;"&amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript" src="&lt;a href="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js%22%3E%3C/script"&gt;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&amp;gt;&amp;lt;/script&lt;/a&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(function () {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#fName").focus();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text" id="fName"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text" id="lName"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/I8LP1--EIcw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/2387120567672677624/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/11/jquery-auto-focus.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/2387120567672677624?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/2387120567672677624?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/I8LP1--EIcw/jquery-auto-focus.html" title="jQuery auto focus." /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/11/jquery-auto-focus.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8GR3s_cSp7ImA9WhJaEEU.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-1041497743506665083</id><published>2012-10-01T15:03:00.000+05:30</published><updated>2012-10-01T15:17:06.549+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-01T15:17:06.549+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="asp.net" /><title>Using RequiredFieldValidator to validate controls | asp.net </title><content type="html">&lt;p&gt;
In ASP.NET there exists a set of validation server control which are useful to validate the data on form. In this post we will see how to use RequiredFieldValidator.&lt;/p&gt;
&lt;p&gt;
RequiredFieldValidator is used to check if field on the form is not empty. In order to use RequiredFiledValidator, we need to add server control &lt;requiredfieldvalidator&gt;on web form. After adding control on page we need to associate the RequiredFieldValidator control to the control that we have to validate. e.g. Textbox. Also we need to set error message to show when validation fails.&lt;/requiredfieldvalidator&gt;&lt;/p&gt;
&lt;p&gt;
RequiredFieldValidator example&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;
&amp;lt;head runat="server"&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;div&amp;gt;
        Name:&amp;lt;br /&amp;gt;
        &amp;lt;asp:TextBox runat="server" ID="Name" /&amp;gt;
        &amp;lt;asp:RequiredFieldValidator runat="server" ID="validateName" ControlToValidate="Name"
            ErrorMessage="Enter the name." ForeColor="Red" /&amp;gt;
        &amp;lt;br /&amp;gt;
        &amp;lt;br /&amp;gt;
        &amp;lt;asp:Button runat="server" ID="btnSubmit" Text="Ok" OnClick="Post_Page" CausesValidation="" /&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code&gt;

&lt;p&gt;Here you will notice that the validation is happening at client side means without postback, this is because by default validator control does client side validation if browser supports DHTML. And if browser does not supports scripting then it will do server side validation, means page will postback and it will check for &lt;b&gt;"Page.IsValid()"&lt;/b&gt; and then will return true or false.&lt;/p&gt;

&lt;p&gt;And if we explicitly want to do the server side validation then we need to set &lt;b&gt;EnableClientScript="false"&lt;/b&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/1vvlTKnzHAo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/1041497743506665083/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/10/using-requiredfieldvalidator-to.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/1041497743506665083?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/1041497743506665083?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/1vvlTKnzHAo/using-requiredfieldvalidator-to.html" title="Using RequiredFieldValidator to validate controls | asp.net " /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://www.codegateway.com/2012/10/using-requiredfieldvalidator-to.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YESHs4fSp7ImA9WhBQEEs.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-5971037629517953927</id><published>2012-09-28T10:01:00.000+05:30</published><updated>2013-03-12T10:41:49.535+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-12T10:41:49.535+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>Detect IE browser | jQuery</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In previous post we saw how to &lt;a href="/2012/09/detect-ie-browser-javascript.html"&gt;get IE browser in JavaScript&lt;/a&gt;&lt;br /&gt;
In this post we wiil see how to detect IE browser using jQuery. jQuery have Browser object like Navigator object in JavaScript. And using Browser object we can get Browser name, version..etc.

&lt;br /&gt;
jQuery to get IE browser&lt;br /&gt;
&lt;code&gt;
&lt;/code&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;
&amp;lt;head runat="server"&amp;gt;
      &amp;lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
    function getBrowser() {
    
        if ($.browser.msie) {
            alert('Detected IE browser');
        }
    }
&amp;lt;/script&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;div&amp;gt;
    &amp;lt;input type="button" onclick="getBrowser();" value="Get Browser Name"/&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;code&gt;
&lt;/code&gt;
&lt;samp&gt;
 &lt;pre&gt;&lt;b&gt;Output&lt;/b&gt; This will show alert message Detected IE browser.&lt;/pre&gt;
&lt;/samp&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/qKcZLe3rqqg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/5971037629517953927/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/09/detect-ie-browser-jquery.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/5971037629517953927?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/5971037629517953927?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/qKcZLe3rqqg/detect-ie-browser-jquery.html" title="Detect IE browser | jQuery" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/09/detect-ie-browser-jquery.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4GRHoyfSp7ImA9WhJbGE0.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-8315565227108213887</id><published>2012-09-27T16:31:00.000+05:30</published><updated>2012-09-28T10:05:25.495+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-28T10:05:25.495+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Javascript" /><title>Detect IE browser | Javascript</title><content type="html">&lt;p&gt;
While working with Web projects those required cross browser compatibility we often need to detect the browser type,like ie, Firefox Mozilla, or chrome...etc.&lt;/p&gt;

&lt;p&gt;
In this post we will see how to find ie browser. This is done using navigator object in JavaScript. Navigator has appName property that we can use to find ie browser.&lt;/p&gt;
&lt;p&gt;
JavaScript to detect ie&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;
&amp;lt;head runat="server"&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
    function getBrowserName()
    {
        if(navigator.appName=="Microsoft Internet Explorer") {
            alert("This is " + navigator.appName + " Browser");
        }
  }
&amp;lt;/script&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;div&amp;gt;
    &amp;lt;input type="button" onclick="return getBrowserName();" value="Get Browser Name"/&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;samp&gt;
 &lt;pre&gt;//Above code will show alert message "This is Microsoft Internet Explorer Browser"&lt;/pre&gt;
&lt;/samp&gt;
&lt;p&gt;Here we will see how to &lt;a href="/2012/09/detect-ie-browser-jquery.html"&gt;detect IE browser using jQuery&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/KrLruDMyu_M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/8315565227108213887/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/09/detect-ie-browser-javascript.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8315565227108213887?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8315565227108213887?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/KrLruDMyu_M/detect-ie-browser-javascript.html" title="Detect IE browser | Javascript" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/09/detect-ie-browser-javascript.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YNQ3gyeCp7ImA9WhBQEEs.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-1913812266141252359</id><published>2012-05-13T19:12:00.001+05:30</published><updated>2013-03-12T10:43:12.690+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-12T10:43:12.690+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery Checkbox" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>jQuery check uncheck all checkboxes in gridview</title><content type="html">&lt;p&gt;
In this post we will see how to check and uncheck checkboxes in the gridview. We will check and uncheck checkboxes at client side in gridview using jquery. First we will add check boxes to gridview like:&lt;/p&gt;

&lt;h2&gt;Gridview with checkboxes&lt;/h2&gt;
&lt;code&gt;&lt;pre&gt;&amp;lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderWidth="1px"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CellPadding="3" BorderStyle="None" Font-Names="Arial"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FooterStyle&amp;gt;&amp;lt;/FooterStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;PagerStyle HorizontalAlign="Left"&amp;gt;&amp;lt;/PagerStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;HeaderStyle Font-Bold="True"&amp;gt;&amp;lt;/HeaderStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Columns&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TemplateField HeaderText="Select"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;HeaderTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:CheckBox ID="checkAll" runat="server" Text="" onclick="javascript:CheckUnCheckAll(this);" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/HeaderTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ItemTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:CheckBox ID="CheckBoxPurchase" runat="server" Enabled="true" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ItemTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:TemplateField&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:BoundField HeaderText="Item No." DataField="ItemNo"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"&amp;gt;&amp;lt;/ItemStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:BoundField&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:BoundField HeaderText="Item Name" DataField="ItemName"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"&amp;gt;&amp;lt;/ItemStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:BoundField&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Columns&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:GridView&amp;gt;
&lt;/pre&gt;
&lt;/code&gt;
&lt;p&gt;Here in above code we have gridview with one checkbox in header and checkboxes for all the rows. Now we have to check all the checkboxes in gridview rows when header checkbox is checked and when header checkbox is unchecked all checkbox get unchecked. Now we have to access gridview object in jquery.&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;$('#&amp;lt;%=GridView1.ClientID %&amp;gt;')&lt;/pre&gt;
&lt;/code&gt;

&lt;p&gt;
In order to get and perform check-uncheck operation on checkboxes we have to call Javascript function from header checkbox of the gridview and in that function we will find all row checkboxes like:&lt;br /&gt;
&lt;code&gt;&lt;pre&gt;&amp;nbsp;$('#&amp;lt;%=GridView1.ClientID %&amp;gt;').find("input:checkbox")&lt;/pre&gt;
&lt;/code&gt;&lt;/p&gt;
Now by iterating through each checkbox item we can assign header checkbox's checked status to all other checkboxes.&lt;br /&gt;
&lt;h2&gt;

Iterate through gridview checkboxes to check uncheck checkboxes&lt;/h2&gt;
&lt;code&gt;&lt;pre&gt;&amp;lt;script type="text/javascript"&amp;gt;
&amp;nbsp; function CheckUnCheckAll(chk) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $('#&amp;lt;%=GridView1.ClientID %&amp;gt;').find("input:checkbox").each(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (this != chk) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.checked = chk.checked;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
 &amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;h2&gt;
Example to check-uncheck all checkboxes in gridview&lt;/h2&gt;

&lt;code&gt;&lt;pre&gt;
&amp;lt;html xmlns="&lt;a href="http://www.w3.org/1999/xhtml"&gt;http://www.w3.org/1999/xhtml&lt;/a&gt;"&amp;gt;
&amp;lt;head runat="server"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript" src="&lt;a href="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js%22%3E%3C/script"&gt;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&amp;gt;&amp;lt;/script&lt;/a&gt;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;Check all checkboxes in gridview using jQuery&amp;lt;/title&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function CheckUnCheckAll(chk) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $('#&amp;lt;%=GridView1.ClientID %&amp;gt;').find("input:checkbox").each(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (this != chk) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.checked = chk.checked;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderWidth="1px"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CellPadding="3" BorderStyle="None" Font-Names="Arial"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FooterStyle&amp;gt;&amp;lt;/FooterStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;PagerStyle HorizontalAlign="Left"&amp;gt;&amp;lt;/PagerStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;HeaderStyle Font-Bold="True"&amp;gt;&amp;lt;/HeaderStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Columns&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TemplateField HeaderText="Select"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;HeaderTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:CheckBox ID="checkAll" runat="server" Text="" onclick="javascript:CheckUnCheckAll(this);" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/HeaderTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ItemTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:CheckBox ID="CheckBoxPurchase" runat="server" Enabled="true" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ItemTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:TemplateField&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:BoundField HeaderText="Item No." DataField="ItemNo"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"&amp;gt;&amp;lt;/ItemStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:BoundField&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:BoundField HeaderText="Item Name" DataField="ItemName"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"&amp;gt;&amp;lt;/ItemStyle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:BoundField&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Columns&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:GridView&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="button" id="submit" value="Submit" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;/code&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/w5KzEDNoVTU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/1913812266141252359/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/05/jquery-check-uncheck-all-checkboxes-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/1913812266141252359?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/1913812266141252359?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/w5KzEDNoVTU/jquery-check-uncheck-all-checkboxes-in.html" title="jQuery check uncheck all checkboxes in gridview" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/05/jquery-check-uncheck-all-checkboxes-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQFQnw6cSp7ImA9WhVVFUU.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-8360350718886662238</id><published>2012-05-08T22:56:00.002+05:30</published><updated>2012-05-09T22:21:53.219+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-09T22:21:53.219+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery Ajax" /><category scheme="http://www.blogger.com/atom/ns#" term="json" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>jQuery call page codebehind method</title><content type="html">&lt;p&gt;
&lt;img src="http://codegateway.googlecode.com/files/blank.png" title="jquery ajax call page code behind method"/&gt;In asp.net application sometimes we need to call codebehind method from client script.&lt;img src="http://codegateway.googlecode.com/files/blank.png" title="jquery ajax call page method"/&gt; In this post we will see how to call codebehind page method using jquery ajax.&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://codegateway.googlecode.com/files/blank.png" title="jquery ajax call aspx code behind method "/&gt;To call codebehind page method from jquery we need to make method static. Also we need to add [WebMethod] attribute for method. So the code behind method will look like:&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;pre&gt; [WebMethod]
  public static string GetMessage()
  {
   return "Codebehind method call...";
  }
&lt;/pre&gt;
&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://codegateway.googlecode.com/files/blank.png" title="jquery call code behind method"/&gt;We also need to add namespace using System.Web.Services; to add [WebMethod] attribute to code behind method.&lt;br /&gt;
Now we can call this codebehind method using jquery ajax like&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;var loc = window.location.href;
$.ajax({
         type: 'POST',
          url: loc + "/GetMessage",
          data: "{}",
          contentType: "application/json; charset=utf-8"
        
        })
        .success(function (response) {
          alert(response.d);

        })
        .error(function (response) {
          alert(response.d);
        });
&lt;/pre&gt;
&lt;/code&gt;

&lt;p&gt;
&lt;img src="http://codegateway.googlecode.com/files/blank.png" title="jquery ajax page code behind method call"/&gt;Here using window.location.href we are getting url of aspx page and by appending method name to it we can call code behind method.&lt;/p&gt;&lt;p&gt;
Below code demonstrats how to call codebehind method using jquery ajax and json&lt;br /&gt;
&lt;h2&gt;jQuery ajax call codebehind  page method&lt;/h2&gt;
&lt;code&gt;&lt;pre&gt;
&amp;lt;html xmlns="&lt;a href="http://www.w3.org/1999/xhtml"&gt;http://www.w3.org/1999/xhtml&lt;/a&gt;"&amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;script type="text/javascript" src="&lt;a href="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js%22%3E%3C/script"&gt;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&amp;gt;&amp;lt;/script&lt;/a&gt;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;script type="text/javascript"&amp;gt;&lt;/p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $(document).ready(function () {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var loc = window.location.href;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#btnClick").click(function (event) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $.ajax({&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type: 'POST',&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url: loc + "/GetMessage",&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data: "{}",&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contentType: "application/json; charset=utf-8"&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .success(function (response) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert(response.d);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .error(function (response) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert(response.d);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Button ID="btnClick" runat="server" Text="Button" /&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&amp;nbsp;
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;&lt;img src="http://codegateway.googlecode.com/files/blank.png" title="ajax call page method"/&gt;Below is the code behind method that will get called by jquery ajax call:
&lt;code&gt;&lt;pre&gt;
using System;
using System.Web.Services;

namespace aspnetcontrol
{
  public partial class jquerycallpagemethod : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    [WebMethod]
    public static string GetMessage()
    {
      return "Codebehind method call...";
    }
  }
}
&lt;/pre&gt;&lt;/code&gt;
&lt;img src="http://codegateway.googlecode.com/files/blank.png" title="jquery ajax call page code behind method"/&gt;
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/S6n2N2_PHdc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/8360350718886662238/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/05/jquery-call-page-codebehind-method.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8360350718886662238?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8360350718886662238?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/S6n2N2_PHdc/jquery-call-page-codebehind-method.html" title="jQuery call page codebehind method" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/05/jquery-call-page-codebehind-method.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUQCQ3g5fip7ImA9WhVVFEU.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-3866385303453282252</id><published>2012-05-08T19:55:00.000+05:30</published><updated>2012-05-08T19:59:22.626+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-08T19:59:22.626+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="blogger tricks" /><category scheme="http://www.blogger.com/atom/ns#" term="blogspot tricks" /><title>Remove Hide blogger|blogspot header navbar</title><content type="html">&lt;p&gt;Blogger or Blogspot is the easy way to write blogs. In blogger by default it shows header navbar on top. To hide blogspot|blogger navbar from header follow the below steps:&lt;br/&gt;

1. Login to blogger account.&lt;br /&gt;
2. Go to Template in new blogger view&lt;br /&gt;
3. Then click on Edit Html.&lt;br /&gt;

&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-Y316V-7e5V4/T6krUHVaBKI/AAAAAAAAA9I/JCFTCpqeGzY/s1600/remove_blogger_blogspot_navbar_header.PNG" imageanchor="1" style=""&gt;&lt;img border="0" height="88" width="200" src="http://2.bp.blogspot.com/-Y316V-7e5V4/T6krUHVaBKI/AAAAAAAAA9I/JCFTCpqeGzY/s200/remove_blogger_blogspot_navbar_header.PNG" alt="hide remove blogspot header navbar using css" title="Remove blogger default header navbar"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;br/&gt;

4. Search for  &amp;lt;b:skin&amp;gt;&lt;br /&gt;

5. Below that add css:&lt;br /&gt;
&lt;code&gt;&lt;pre&gt;
#navbar-iframe
{
height:0px;
visibility:hidden;
display:none;
}&lt;/pre&gt;&lt;/code&gt;
This will hide or disable the blogger default header navbar.
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/-DFarwuq-mg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/3866385303453282252/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/05/remove-hide-bloggerblogspot-header.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/3866385303453282252?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/3866385303453282252?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/-DFarwuq-mg/remove-hide-bloggerblogspot-header.html" title="Remove Hide blogger|blogspot header navbar" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-Y316V-7e5V4/T6krUHVaBKI/AAAAAAAAA9I/JCFTCpqeGzY/s72-c/remove_blogger_blogspot_navbar_header.PNG" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://www.codegateway.com/2012/05/remove-hide-bloggerblogspot-header.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQHR3oyfip7ImA9WhVWEks.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-7793827939354343932</id><published>2012-04-24T15:58:00.001+05:30</published><updated>2012-04-24T16:15:36.496+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-24T16:15:36.496+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery Ajax" /><category scheme="http://www.blogger.com/atom/ns#" term="json" /><category scheme="http://www.blogger.com/atom/ns#" term="wcf" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>jQuery ajax handle exception thrown by wcf</title><content type="html">&lt;p&gt;
When we work with jQuery Ajax call to WCF, it may possible that WCF service will thow an exception. And we need to catch that exception in jquery ajax error routine. In order to show or get exception thrown by service we need to configure includeExceptionDetailInFaults="True" for &lt;servicedebug&gt; in behavior like:
&lt;br /&gt;
&lt;code&gt;&lt;pre&gt;&amp;lt;serviceBehaviors&amp;gt;
&amp;nbsp; &amp;lt;behavior name=""&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceMetadata httpGetEnabled="true" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceDebug includeExceptionDetailInFaults="true" /&amp;gt;
&amp;nbsp; &amp;lt;/behavior&amp;gt;
&amp;lt;/serviceBehaviors&amp;gt;
&lt;/pre&gt;
&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Now when jquery ajax call revices error then exception comes in resposeText as Message.But we need extract Message from responseText as responseText comes as cominations of error details. This can be done using jQuery.parseJSON like:
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;pre&gt; .error(function (response, q, t) {
          var r = jQuery.parseJSON(response.responseText);
        });
&lt;/pre&gt;
&lt;/code&gt;
&lt;br /&gt;
Now to get Message part we can use r.Message. This will give you the message that is sent by exception in wcf service.
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;pre&gt; .error(function (response, q, t) {
          var r = jQuery.parseJSON(response.responseText);
          alert("Message: " + r.Message);
        });
&lt;/pre&gt;
&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;h2&gt;
Code for jQuery ajax handle exception thrown by wcf&lt;code&gt;&lt;/code&gt;&lt;/h2&gt;
&lt;code&gt;&lt;pre&gt;&amp;lt;html xmlns="&lt;a href="http://www.w3.org/1999/xhtml"&gt;http://www.w3.org/1999/xhtml&lt;/a&gt;"&amp;gt;
&amp;lt;head runat="server"&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript" src="&lt;a href="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js%22%3E%3C/script"&gt;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&amp;gt;&amp;lt;/script&lt;/a&gt;&amp;gt;
&amp;nbsp; &amp;lt;title&amp;gt;Jquery ajax json call to wcf service&amp;lt;/title&amp;gt;
&amp;nbsp; &amp;lt;script type="text/javascript"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $(document).ready(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#btnClick").click(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var dto = { message: $("#messageinput").val() };
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $.ajax({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type: 'GET',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url: '&amp;lt;%= ResolveUrl("~/Service1.svc/get-json/GetMessage") %&amp;gt;',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data: dto,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contentType: "application/json; charset=utf-8"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .success(function (response) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert(response.d);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .error(function (response, q, t) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var r = jQuery.parseJSON(response.responseText);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("Message: " + r.Message);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("StackTrace: " + r.StackTrace);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("ExceptionType: " + r.ExceptionType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("ERROR" + response.d);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp; &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;
&amp;nbsp; &amp;lt;div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text" id="messageinput" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Button ID="btnClick" runat="server" Text="Button" /&amp;gt;
&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;nbsp; &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Note: To test example of catch exception in jquery ajax thrown by wcf service, just throw an application exception or Exception with some message like:
&lt;code&gt;&lt;pre&gt;
    [WebGet()]
    [OperationContract]
    public string GetMessage(string message)
    {
      //return "WCF" + message;
      throw  new  ApplicationException("This is exception");
    }
&lt;/pre&gt;&lt;/code&gt;

&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/jW1grUL0nR4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/7793827939354343932/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/04/jquery-ajax-handle-exception-thrown-by.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/7793827939354343932?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/7793827939354343932?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/jW1grUL0nR4/jquery-ajax-handle-exception-thrown-by.html" title="jQuery ajax handle exception thrown by wcf" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>3</thr:total><feedburner:origLink>http://www.codegateway.com/2012/04/jquery-ajax-handle-exception-thrown-by.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQMR3w_eip7ImA9WhVXGUU.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-4828364912467618578</id><published>2012-04-20T22:47:00.003+05:30</published><updated>2012-04-21T09:56:26.242+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-21T09:56:26.242+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery Ajax" /><category scheme="http://www.blogger.com/atom/ns#" term="json" /><category scheme="http://www.blogger.com/atom/ns#" term="wcf" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>Configure wcf service to call in jquery ajax json</title><content type="html">&lt;p&gt;
In previous post we saw &lt;a href="/2012/04/create-wcf-service-to-call-by-jquery.html"&gt;how to create wcf service&lt;/a&gt; to be get called by jquery ajax and json. After creating wcf service we need to configure wcf service in web.config in order to make it accessible.&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-dRiTMwFP28w/T5Gfkx4nCTI/AAAAAAAAA8w/KzXb142LcC4/s1600/configure-wcf-service-jquery-ajax-json.png" imageanchor="1" style="clear:right; float:right; margin-left:1em; margin-bottom:1em"&gt;&lt;img border="0" height="72" width="72" src="http://2.bp.blogspot.com/-dRiTMwFP28w/T5Gfkx4nCTI/AAAAAAAAA8w/KzXb142LcC4/s200/configure-wcf-service-jquery-ajax-json.png" title="configure wcf service in web.config" alt="wcf service configuration for jquery ajax call"/&gt;&lt;/a&gt;&lt;/div&gt;

&lt;/p&gt;&lt;p&gt;&lt;h2&gt;
Configure wcf service&lt;/h2&gt;
&lt;code&gt;&lt;pre&gt;
&amp;nbsp; &amp;lt;system.serviceModel&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behaviors&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpointBehaviors&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behavior name="GetJson"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;enableWebScript /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behavior&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behavior name="PostJson"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;webHttp /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behavior&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/endpointBehaviors&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceBehaviors&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behavior name=""&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceMetadata httpGetEnabled="true" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceDebug includeExceptionDetailInFaults="false" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behavior&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/serviceBehaviors&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behaviors&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;services&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;service name="aspnetcontrol.Service1"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address="get-json"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding="webHttpBinding"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; behaviorConfiguration="GetJson"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contract="aspnetcontrol.Service1" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address="post-json"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding="webHttpBinding"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; behaviorConfiguration="PostJson"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contract="aspnetcontrol.Service1" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/service&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/services&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/system.serviceModel&amp;gt;&lt;/pre&gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/Z9CwWDxbYPY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/4828364912467618578/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/04/configure-wcf-service-to-call-in-jquery.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/4828364912467618578?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/4828364912467618578?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/Z9CwWDxbYPY/configure-wcf-service-to-call-in-jquery.html" title="Configure wcf service to call in jquery ajax json" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-dRiTMwFP28w/T5Gfkx4nCTI/AAAAAAAAA8w/KzXb142LcC4/s72-c/configure-wcf-service-jquery-ajax-json.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/04/configure-wcf-service-to-call-in-jquery.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEMFQX4yeCp7ImA9WhVXGUU.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-4928160537890459123</id><published>2012-04-20T22:26:00.000+05:30</published><updated>2012-04-21T09:56:50.090+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-21T09:56:50.090+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery Ajax" /><category scheme="http://www.blogger.com/atom/ns#" term="json" /><category scheme="http://www.blogger.com/atom/ns#" term="wcf" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>Create wcf service to call by jquery ajax json</title><content type="html">&lt;p&gt;
In this post we will see how to create wcf service in C# that we can call through jquery ajax and json. The namespaces we need in wcf service are System.ServiceModel, System.ServiceModel.Web and System.ServiceModel.Activation.
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-LY2jYVsD54E/T5GRJmABXzI/AAAAAAAAA8k/XhaBy9kDgrg/s1600/wcf-service-jquery-ajax-json.png" imageanchor="1" style="clear:right; float:right; margin-left:1em; margin-bottom:1em"&gt;&lt;img border="0" height="72" width="72" src="http://3.bp.blogspot.com/-LY2jYVsD54E/T5GRJmABXzI/AAAAAAAAA8k/XhaBy9kDgrg/s200/wcf-service-jquery-ajax-json.png" title="wcf service for jquery ajax and json" alt="create wcf service to be called by jquery ajax json"/&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;&lt;h2&gt;Example- WCF service to call by jquery ajax json&lt;/h2&gt;
&lt;code&gt;&lt;pre&gt;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.ServiceModel.Activation;
using System.Web;

namespace aspnetcontrol
{
  [ServiceContract(Namespace = "")]
  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  public class Service1 
  {
    [WebGet()]
    [OperationContract]
    public string GetMessage(string message)
    {
      return "WCF" + message;
    }
  }
}

&lt;/pre&gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;Note: In above code important attributes are [ServiceContract(Namespace = "")], [OperationContract] and [WebGet()].
ServiceContract specifies that class defines service contract in application.&lt;/br&gt;
OperationContract specifies that a method defines and operation that is part of web service contract. &lt;/br&gt;
WebGet indicates service operation is logically a retrieval operation.&lt;/ br&gt;
In this way we can create wcf service to be called using jquery ajax json. In order to make service accessible we need to &lt;a href="/2012/04/configure-wcf-service-to-call-in-jquery.html"&gt;configure wcf service in web.config&lt;/a&gt;.
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/o-Bb2CWBhSY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/4928160537890459123/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/04/create-wcf-service-to-call-by-jquery.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/4928160537890459123?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/4928160537890459123?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/o-Bb2CWBhSY/create-wcf-service-to-call-by-jquery.html" title="Create wcf service to call by jquery ajax json" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-LY2jYVsD54E/T5GRJmABXzI/AAAAAAAAA8k/XhaBy9kDgrg/s72-c/wcf-service-jquery-ajax-json.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/04/create-wcf-service-to-call-by-jquery.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEMGRXo_fSp7ImA9WhVXGUU.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-4663204230468063318</id><published>2012-04-20T21:56:00.000+05:30</published><updated>2012-04-21T09:57:04.445+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-21T09:57:04.445+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery Ajax" /><category scheme="http://www.blogger.com/atom/ns#" term="json" /><category scheme="http://www.blogger.com/atom/ns#" term="wcf" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>jQuery Ajax call to WCF service</title><content type="html">&lt;p&gt;
In jQuery we can perform an asynchronous HTTP (Ajax) request. In this post we will see simple example of how jquery Ajax call to WCF service works. We can call wcf service using jquery ajax and json. &lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-i6QLi_ogbl0/T4b4GIDuSBI/AAAAAAAAA70/89QuxOdnSck/s1600/jquery-ajax-json-wcf-service-call.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="72" src="http://3.bp.blogspot.com/-i6QLi_ogbl0/T4b4GIDuSBI/AAAAAAAAA70/89QuxOdnSck/s200/jquery-ajax-json-wcf-service-call.png" width="72" title="call wcf service using jquery ajax" alt="use jquery ajax to call wcf service" /&gt;&lt;/a&gt;&lt;/div&gt;
We can use $.ajax to call the wcf service like:
&lt;code&gt;&lt;pre&gt; var dto = { message: $("#messageinput").val() };
        $.ajax({
          type: 'GET',
          url: '',
          data: dto,
          contentType: "application/json; charset=utf-8"
        })
        .success(function (response) {
          alert(response.d);
        })
        .error(function (response) {
          alert("ERROR"+response.d);
        });
&lt;/pre&gt;
&lt;/code&gt;
&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;Here in above code snippet we have set various parameters for jquery ajax call like: &lt;b&gt;type: 'GET'&lt;/b&gt; - means request is of type GET and not POST&lt;br /&gt;
&lt;b&gt;url: ''&lt;/b&gt;, here we have mentioned the url of wcf service, where Service1.svc is wcf service name, get-json is address set in the web.config wcf service &lt;endpoint&gt; and GetMessage is actual method in wcf service.&lt;br /&gt;
&lt;b&gt;data: dto&lt;/b&gt; is the parameter data that we need to pass to wcf service method. 
&lt;/endpoint&gt;&lt;/p&gt;
&lt;h2&gt;
Example jquery ajax call to wcf service&lt;/h2&gt;
&lt;code&gt;&lt;pre&gt;&amp;lt;html xmlns="&lt;a href="http://www.w3.org/1999/xhtml"&gt;http://www.w3.org/1999/xhtml&lt;/a&gt;"&amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript" src="&lt;a href="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js%22%3E%3C/script"&gt;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&amp;gt;&amp;lt;/script&lt;/a&gt;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;title&amp;gt;Jquery ajax json call to wcf service&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; $(document).ready(function () {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#btnClick").click(function () {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var dto = { message: $("#messageinput").val() };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $.ajax({&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type: 'GET',&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url: '&amp;lt;%= ResolveUrl("~/Service1.svc/get-json/GetMessage") %&amp;gt;',&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data: dto,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contentType: "application/json; charset=utf-8"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .success(function (response) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert(response.d);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .error(function (response) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("ERROR"+response.d);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text" id="messageinput" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Button ID="btnClick" runat="server" Text="Button" /&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;In above example we can type some message in textbox and pass message to wcf service using jquery ajax call and get it in respose back.&lt;/p&gt;
&lt;p&gt;Note: To run above example we need to &lt;a href="/2012/04/create-wcf-service-to-call-by-jquery.html"&gt;create wcf service &lt;/a&gt;and &lt;a href="/2012/04/configure-wcf-service-to-call-in-jquery.html"&gt;configure wcf service endpoint in web.config &lt;/a&gt;file properly&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/u-ssf6jmcy0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/4663204230468063318/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/04/jquery-ajax-call-to-wcf-service.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/4663204230468063318?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/4663204230468063318?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/u-ssf6jmcy0/jquery-ajax-call-to-wcf-service.html" title="jQuery Ajax call to WCF service" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-i6QLi_ogbl0/T4b4GIDuSBI/AAAAAAAAA70/89QuxOdnSck/s72-c/jquery-ajax-json-wcf-service-call.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/04/jquery-ajax-call-to-wcf-service.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUUCRnY4fyp7ImA9WhVQGEw.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-8489673294760455850</id><published>2012-04-07T14:58:00.000+05:30</published><updated>2012-04-07T22:17:47.837+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-07T22:17:47.837+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery dropdown" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title>jquery set dropdownlist exact text</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
We have seen how to set selected option in dropdown list by text here &lt;a href="http://www.blogger.com/2012/03/set-selected-option-by-text-of.html"&gt;set dropdownlist selected option by text&lt;/a&gt;. In that example we used :contains selector that will look for the text and the &lt;b&gt;set text in dropdownlist&lt;/b&gt; as selected.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-yriODyLlHzk/T3_7OX4LtDI/AAAAAAAAA7o/R12v2HIIYWo/s1600/set-selected-option-by-exact-text-in-dropdownlist-using-jquery.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img alt="dropdownlist set exact selected text" border="0" height="72" src="http://2.bp.blogspot.com/-yriODyLlHzk/T3_7OX4LtDI/AAAAAAAAA7o/R12v2HIIYWo/s200/set-selected-option-by-exact-text-in-dropdownlist-using-jquery.png" title="set dropdownlist selected text exact" width="72" /&gt;&lt;/a&gt;&lt;/div&gt;
But if dropdownlist have items with same texts instance then :contains selector will get all the items with matched text. This might show last matched item selected in dropdownlist. In this case we need to use alternate way to get &lt;b&gt;exact text in dropdownlist&lt;/b&gt; and then set it selected.&lt;br /&gt;
&lt;h2&gt;

Example to set selected option in dropdown by exact text [jquery]&lt;/h2&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;pre&gt;&amp;lt;html xmlns="&lt;a href="http://www.w3.org/1999/xhtml"&gt;http://www.w3.org/1999/xhtml&lt;/a&gt;"&amp;gt;
&amp;lt;head id="Head1" runat="server"&amp;gt;
&amp;nbsp; &amp;lt;script type="text/javascript" src="&lt;a href="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js%22%3E%3C/script"&gt;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&amp;gt;&amp;lt;/script&lt;/a&gt;&amp;gt;
&amp;nbsp; &amp;lt;title&amp;gt;set dropdown value&amp;lt;/title&amp;gt;
&amp;nbsp; &amp;lt;script type="text/javascript"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $(document).ready(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#go").click(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var inputText = $("#inputText").val();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#numbers").each(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $('option', this).each(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($.trim($(this).text().toLowerCase()) == $.trim(inputText.toLowerCase())) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(this).attr('selected', 'selected');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };
&amp;nbsp;&amp;nbsp;        });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;
&amp;nbsp; &amp;lt;div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label&amp;gt;Enter value from dropdown&amp;lt;/label&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text" id="inputText" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:DropDownList ID="numbers" runat="server"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:ListItem Text="This is one" Value="1"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:ListItem Text="This is one?" Value="2"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:ListItem Text="This is three" Value="3"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:DropDownList&amp;gt;
&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;nbsp; &amp;lt;input type="button" id="go" value="Go" /&amp;gt;
&amp;nbsp; &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;/code&gt;
&lt;b&gt;Summary:&lt;/b&gt; So by using :contains it might not work for multiple items with istance of same text. But we can iterate through dropdown items and then by matching exact text we can set dropdown list text selected.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/1BxJnguFXW4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/8489673294760455850/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/04/jquery-set-dropdownlist-exact-text.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8489673294760455850?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/8489673294760455850?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/1BxJnguFXW4/jquery-set-dropdownlist-exact-text.html" title="jquery set dropdownlist exact text" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-yriODyLlHzk/T3_7OX4LtDI/AAAAAAAAA7o/R12v2HIIYWo/s72-c/set-selected-option-by-exact-text-in-dropdownlist-using-jquery.png" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://www.codegateway.com/2012/04/jquery-set-dropdownlist-exact-text.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEEDSHY8eyp7ImA9WhVQF0U.&quot;"><id>tag:blogger.com,1999:blog-422673690916585356.post-6875592203119672445</id><published>2012-03-30T12:08:00.004+05:30</published><updated>2012-04-07T13:47:59.873+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-07T13:47:59.873+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jQuery dropdown" /><title>Dropdownlist set selected value</title><content type="html">&lt;p&gt;In this post we will see in jquery how to&lt;b&gt;set dropdown list value &lt;/b&gt; or selected option by it's value. For that we simply need to get object of dropdown list in jquery and then we can set selected option by using val(). of dropdownlist.&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-yl_YQj-TZN0/T3kwN_juKHI/AAAAAAAAA7Y/lD9IQ173ZFg/s1600/set-selected-option-to-dropdownlist-by-value-using-jquery.png" imageanchor="1" style="clear:right; float:right; margin-left:1em; margin-bottom:1em"&gt;&lt;img border="0" height="72" width="72" src="http://1.bp.blogspot.com/-yl_YQj-TZN0/T3kwN_juKHI/AAAAAAAAA7Y/lD9IQ173ZFg/s200/set-selected-option-to-dropdownlist-by-value-using-jquery.png" title="jquery dropdownlist set selected option by value" alt="jquery dropdownlist set selected value" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;&lt;h2&gt;Example: set dropdown list selected option by value [jQuery]&lt;/h2&gt;&lt;code&gt;&lt;pre&gt;&amp;lt;html xmlns="&lt;a href="http://www.w3.org/1999/xhtml"&gt;http://www.w3.org/1999/xhtml&lt;/a&gt;"&amp;gt;
&amp;lt;head id="Head1" runat="server"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript" src="&lt;a href="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js%22%3E%3C/script"&gt;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&amp;gt;&amp;lt;/script&lt;/a&gt;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;jQuery set dropdown list selected option by value&amp;lt;/title&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(document).ready(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#go").click(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var inputText = $("#inputText").val();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#numbers").val(inputText);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label&amp;gt;Enter value between 1-3&amp;lt;/label&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text" id="inputText"/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:DropDownList ID="numbers" runat="server"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:ListItem Text="1" Value="1"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:ListItem Text="2" Value="2"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:ListItem Text="3" Value="3"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:DropDownList&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="button" id="go" value="Go" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;&lt;b&gt;Summary:&lt;/b&gt; So in short we can use jquery to set dropdownlist item value like $("#numbers").val(inputText);. we can also set dropdown list selected option by using text like &lt;a href="/2012/03/set-selected-option-by-text-of.html"&gt;Set selected value by text.&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~4/2hriyRE2CMc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.codegateway.com/feeds/6875592203119672445/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.codegateway.com/2012/03/set-selected-option-by-value-to.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6875592203119672445?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/422673690916585356/posts/default/6875592203119672445?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MakeItEasyaspnetCDotNetFrameworkClrJqueryClientSideScriptingLinq/~3/2hriyRE2CMc/set-selected-option-by-value-to.html" title="Dropdownlist set selected value" /><author><name>Avinash</name><uri>http://www.blogger.com/profile/11338220988745873438</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-yl_YQj-TZN0/T3kwN_juKHI/AAAAAAAAA7Y/lD9IQ173ZFg/s72-c/set-selected-option-to-dropdownlist-by-value-using-jquery.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.codegateway.com/2012/03/set-selected-option-by-value-to.html</feedburner:origLink></entry></feed>
