<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>asp.net</title>
        <link>http://geekswithblogs.net/rajeshpillai/category/10969.aspx</link>
        <description>Related to asp.net</description>
        <language>en-US</language>
        <copyright>Rajesh Pillai</copyright>
        <managingEditor>thinkrajesh@yahoo.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>jQuery Limit text entry</title>
            <link>http://geekswithblogs.net/rajeshpillai/archive/2009/12/03/jqlimittext.aspx</link>
            <description>&lt;p&gt;Lets quickly have a look at how you can limit the entry to textbox and display the character input left to be keyed in.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;First things first, the script.&lt;/em&gt;&lt;/p&gt;
&lt;pre&gt;
&amp;lt;script type="text/javascript"&amp;gt;
    $(function() {
        var limit = 250;
        $('#dvLimit').text('250 characters left');
        $('textarea[id$=txtDemoLimit]').keyup(function() {
            var len = $(this).val().length;
            if (len &amp;gt; limit) {
                this.value = this.value.substring(0, limit);
            }
            $("#dvLimit").text(limit - len + " characters left");
        });
    });
&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;The $() function does the following things on startup.&lt;/p&gt;
&lt;p&gt;1. Set a variable to a limit of 250 characters.&lt;/p&gt;
&lt;p&gt;2. Assign a default value to the "div" element with id "dvLimit"&lt;/p&gt;
&lt;p&gt;3. Find the control that contains the id "txtDemoLimit" and hook up the keyup event.&lt;/p&gt;
&lt;p&gt;4. In the keyup event get the length of the current text.&lt;/p&gt;
&lt;p&gt;5. If len is greater than the limit set, set the text value as a substring within the specified    limit.&lt;/p&gt;
&lt;p&gt;6. Update the div with the no. of characters left to be keyed in.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The HTML is shown below.&lt;/em&gt;&lt;/p&gt;
&lt;pre&gt;
&amp;lt;div id="dvLimit"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;
    &amp;lt;asp:TextBox ID="txtDemoLimit" TextMode="MultiLine" Columns = "40" Rows = "10" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;
&amp;lt;/div&amp;gt;

The following is the application in action.

&lt;img width="473" height="426" alt="Jquery text box limit demo" src="/images/geekswithblogs_net/rajeshpillai/demo.jpg" /&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Modify this as per your requiement and enjoy jQuerying !!!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;a&lt;/span&gt; &lt;span class="code-attribute"&gt;href&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=48141" style="display:none"&lt;/span&gt; &lt;span class="code-attribute"&gt;rel&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;tag"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;span title="Or any of: 'code project', 'the code project', 'The Code Project'"&gt;CodeProject&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;a&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/rajeshpillai/aggbug/136674.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rajesh Pillai</dc:creator>
            <guid>http://geekswithblogs.net/rajeshpillai/archive/2009/12/03/jqlimittext.aspx</guid>
            <pubDate>Thu, 03 Dec 2009 12:10:31 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/rajeshpillai/comments/136674.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/rajeshpillai/archive/2009/12/03/jqlimittext.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/rajeshpillai/comments/commentRss/136674.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/rajeshpillai/services/trackbacks/136674.aspx</trackback:ping>
        </item>
        <item>
            <title>Tech Tips: C# 3.0 Partial Methods</title>
            <link>http://geekswithblogs.net/rajeshpillai/archive/2009/11/28/tektippartial.aspx</link>
            <description>&lt;h1&gt;c# 3.0 : Partial Method&lt;/h1&gt;
&lt;p class="MsoNormal"&gt;You are all aware of “Partial Class” introduced in .net  2.0.    Partial class is useful in situation where you need to split the  definition of a class, &lt;br /&gt;
struct or an interface over two or more source files.   Each source file contains a section of the type or method  definition and all parts are &lt;br /&gt;
combined when the application is compiled. &lt;/p&gt;
&lt;p class="MsoNormal"&gt;There are several situations when splitting a class  definition is desirable:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;When working  on large projects, spreading a class over separate files enables multiple  programmers to work on it at the same time.&lt;/p&gt;
&lt;p class="MsoListParagraph" style="text-indent: -0.25in;"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;When working  with automatically generated source, code can be added to the class without  having to recreate the source file. Visual Studio &lt;br /&gt;
uses this approach when it  creates Windows Forms, Web service wrapper code, and so on. You can create code  that uses these classes without &lt;br /&gt;
having to modify the file created by Visual  Studio.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;u&gt;Partial Method (.net 3.0):&lt;br /&gt;
&lt;/u&gt;&lt;br /&gt;
 Partial methods are  the code block which reside inside a partial type and gets executed only when it  has definition. This gives us the extensibility &lt;br /&gt;
and if user wants to implement  the rule, they can go ahead and define the body but if they do not want it will  not. This improves the performance as &lt;br /&gt;
you are not loading/creating unwanted  methods. Partial methods are especially useful as a way to customize generated  code. They allow for a &lt;br /&gt;
method name and signature to be reserved, so that  generated code can call the method but the developer can decide whether to  implement the &lt;br /&gt;
method. Much like partial classes, partial methods enable code  created by a code generator and code created by a human developer to work  together &lt;br /&gt;
without run-time costs.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;A partial method declaration consists of two parts: the  definition, and the implementation. These may be in separate parts of a partial  class, or in the &lt;br /&gt;
same part. If there is no implementation declaration, then the  compiler optimizes away both the defining declaration and all calls to the  method.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;// Definition in file1.cs&lt;/p&gt;
&lt;p class="MsoNormal"&gt;partial void onNameChanged(); &lt;/p&gt;
&lt;p class="MsoNormal"&gt;// Implementation in file2.cs&lt;/p&gt;
&lt;p class="MsoNormal"&gt;partial void onNameChanged()&lt;br /&gt;
{&lt;br /&gt;
  // method body&lt;br /&gt;
}&lt;/p&gt;
&lt;ul type="disc"&gt;
    &lt;li class="MsoNormal"&gt;Partial method declarations must begin with the contextual  keyword &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/wbx7zzdd.aspx"&gt;partial&lt;/a&gt; and the method must return &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/yah0tteb.aspx"&gt;void&lt;/a&gt;.&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;Partial methods can have &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/14akc2c7.aspx"&gt;ref&lt;/a&gt; but not &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/t3c3bfhx.aspx"&gt;out&lt;/a&gt; parameters.&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;Partial methods are implicitly &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/st6sy9xe.aspx"&gt;private&lt;/a&gt;, and therefore they cannot be &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/9fkccyh4.aspx"&gt;virtual&lt;/a&gt;.&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;Partial methods cannot be &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/e59b22c5.aspx"&gt;extern&lt;/a&gt;, because the presence of the body determines whether  they are defining or implementing.&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;Partial methods can have &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/98f28cdx.aspx"&gt;static&lt;/a&gt; and &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/chfa2zb8.aspx"&gt;unsafe&lt;/a&gt; modifiers.&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;Partial methods can be generic. Constraints are put on the  defining partial method declaration, and may optionally be repeated on the  implementing one. Parameter and type parameter names do not have to be the same  in the implementing declaration as in the defining one.&lt;/li&gt;
    &lt;li class="MsoNormal"&gt;You can make a &lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/900fyy8e.aspx"&gt;delegate&lt;/a&gt; to a partial method that has been defined and  implemented, but not to a partial method that has only been defined.&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;&lt;span style="text-decoration: none;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;The above knowledge may seem  very miniscule but it opens up a whole new opportunity when you are designing  your system.  &lt;br /&gt;
For e.g.  Microsoft Entity Framework uses this feature for  notifying property changes.&lt;/span&gt;&lt;/u&gt;&lt;u&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;&lt;span style="text-decoration: none;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;But beware there are caveats  to it.&lt;/span&gt;&lt;/u&gt;&lt;span style="color: rgb(31, 73, 125);"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;How can this knowledge be  applied?  Say for e.g. you have a class called “Address” which is declared as  follows&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;public &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"&gt;partial&lt;/span&gt; class Address&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt; {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;      private string  city;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;      public string  City&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;      {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;             get { return  this.city;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;             set &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;             {&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;                     //  If this method is implemented then the actual code will be executed else  this will be ignored.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;                      this.OnCityChanging(value);     //  This is partial method.  No exception will  be thrown if this method is not implemented.  &lt;/span&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;                                                                &lt;br /&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;                     this.city =  value;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;             }&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;      }&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;    &lt;br /&gt;
&lt;/span&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;    &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"&gt;partial&lt;/span&gt; void OnCityChanging (string  city);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(31, 73, 125);"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;public &lt;b&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"&gt;partial&lt;/span&gt;&lt;/b&gt; class Address&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;      &lt;b&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"&gt;partial&lt;/span&gt;&lt;/b&gt; void OnCityChanging(string  city)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;      {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;                // You can add  business rules/validation or constraints here…&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;               If (city ==  “prohibited city”)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;                      throw new  InvalidArgumentException(“This city is not allowed”);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;      }&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Create an instance of  Address…&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Address add = new  Address();&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(31, 73, 125);"&gt;add.City = “prohibited city”;    // exception will be thrown.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;This is just a rudimentary  example to wet up your appetite.&lt;/span&gt; &lt;span style="color: rgb(31, 73, 125);"&gt;Now, wear your “Thinking Hat”  and ponder over when you get some time &lt;br /&gt;
as to where this can be  applied.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Reference:&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://msdn.microsoft.com/en-us/library/wa80x488.aspx"&gt;http://msdn.microsoft.com/en-us/library/wa80x488.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;&lt;a target="_blank" href="/exchweb/bin/redir.asp?URL=http://community.bartdesmet.net/blogs/bart/archive/2007/07/28/c-3-0-partial-methods-what-why-and-how.aspx"&gt;http://community.bartdesmet.net/blogs/bart/archive/2007/07/28/c-3-0-partial-methods-what-why-and-how.aspx&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/rajeshpillai/aggbug/136579.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rajesh Pillai</dc:creator>
            <guid>http://geekswithblogs.net/rajeshpillai/archive/2009/11/28/tektippartial.aspx</guid>
            <pubDate>Sat, 28 Nov 2009 06:11:04 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/rajeshpillai/comments/136579.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/rajeshpillai/archive/2009/11/28/tektippartial.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/rajeshpillai/comments/commentRss/136579.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/rajeshpillai/services/trackbacks/136579.aspx</trackback:ping>
        </item>
        <item>
            <title>In-Place-Edit with jQuery</title>
            <link>http://geekswithblogs.net/rajeshpillai/archive/2009/11/26/in-place-edit-with-jquery.aspx</link>
            <description>&lt;p&gt;Let's try a simple in-place edit with jquery.  For demonstration purpose I am using the plain old HTML file.  However, &lt;br /&gt;
if you, wish you could apply the same technique to asp.net, asp.net mvc or php or any other web application as well.&lt;/p&gt;
&lt;p&gt; Here is the html that we will be using for the demo.&lt;/p&gt;
&lt;p&gt;&amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;div style="line-height:3xm;background-color:skyblue"&amp;gt; &lt;br /&gt;
        Double Click the below paragraph to edit.&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/br&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
    &amp;lt;div class="edit"&amp;gt;&lt;br /&gt;
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. &lt;br /&gt;
        Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis &lt;br /&gt;
        sagittis ipsum. Praesent mauris. &lt;br /&gt;
        Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. &lt;br /&gt;
        Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. &lt;br /&gt;
        Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. &lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;/p&gt;
&lt;p&gt;The element that needs to be made editable is given a class  of "edit".&lt;br /&gt;
 &lt;/p&gt;
&lt;p&gt;The following is the minimal CSS we will be using for this demo.&lt;/p&gt;
&lt;div style="background-color: rgb(251, 237, 187);"&gt;
&lt;p&gt;&amp;lt;style type="text/css"&amp;gt;&lt;br /&gt;
        .edit {&lt;br /&gt;
            width:400px;&lt;br /&gt;
            border:1px dashed orange;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        .saveButton {&lt;br /&gt;
        }&lt;br /&gt;
        .cancelButton {&lt;br /&gt;
        }&lt;/p&gt;
&lt;p&gt; &amp;lt;/style&amp;gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Let's add a reference to the jquery library&lt;/p&gt;
&lt;p&gt;If you have a local copy then refer it as follows&lt;/p&gt;
&lt;pre&gt;
&amp;lt;script src="scripts/jquery-1.3.2.min.js"&amp;gt;&amp;lt;/script&amp;gt; 
&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
The above assumes you have a copy of the jquery library in the scripts folder on your root directory.&lt;/p&gt;
&lt;p&gt;Otherwise you can always grab the latest copy from google..&lt;/p&gt;
&lt;pre&gt;
&amp;lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Now let's setup the event handler to make the div editable.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="background-color: rgb(251, 237, 187);"&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;
  $(function(){&lt;br /&gt;
            setEditable();&lt;br /&gt;
  });&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;p&gt;The $() function is jquery's way of telling the browser to execte the function when the DOM is ready.&lt;/p&gt;
&lt;p&gt;Here' is the setEditable function.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="background-color: rgb(251, 237, 187);"&gt;function setEditable() {&lt;br /&gt;
    $('.edit').click(function() {&lt;br /&gt;
          var textarea = '&amp;lt;div&amp;gt;&amp;lt;textarea&amp;gt;'+$(this).html()+'&amp;lt;/textarea&amp;gt;';&lt;br /&gt;
           var button     = '&amp;lt;div&amp;gt;&amp;lt;input type="button" value="SAVE" class="saveButton" /&amp;gt; &amp;lt;input type="button" value="CANCEL" class="cancelButton" /&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;';&lt;br /&gt;
                var revert = $(this).html();&lt;br /&gt;
                $(this).after(textarea+button).remove();&lt;br /&gt;
                $('.saveButton').click(function(){saveChanges(this, false);});&lt;br /&gt;
                $('.cancelButton').click(function(){saveChanges(this, revert);});&lt;br /&gt;
            })&lt;br /&gt;
  };&lt;/div&gt;
&lt;div style="background-color: rgb(251, 237, 187);"&gt;&lt;br /&gt;
  function trim(stringToTrim) {&lt;br /&gt;
       return stringToTrim.replace(/^\s+|\s+$/g, "");&lt;br /&gt;
  }&lt;/div&gt;
&lt;p&gt;The above function essentially does three things.&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Hook up the click event handler on the element with class ".edit".&lt;/li&gt;
    &lt;li&gt;Inside the function the following are the sequence that happens
    &lt;ol&gt;
        &lt;li&gt;Build the html for inserting a &amp;lt;textarea&amp;gt; for editing.&lt;/li&gt;
        &lt;li&gt;Build the html for inserting a "save" and "cancel" button.&lt;/li&gt;
        &lt;li&gt;Save the current value of the element.&lt;/li&gt;
        &lt;li&gt;Removes the current div (with class .edit) and inserts the above html.&lt;/li&gt;
        &lt;li&gt;Hooks up the events for "save" and "cancel" button.&lt;/li&gt;
    &lt;/ol&gt;
    &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;
&lt;span style="background-color: rgb(153, 204, 255);"&gt;  Note: the jquery function after() inserts content after each of the matched elements.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; The below function is called when you click "save" or "cancel" button&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="background-color: rgb(251, 237, 187);"&gt;&lt;br /&gt;
function saveChanges(obj, cancel) {&lt;br /&gt;
      if (!cancel) {&lt;br /&gt;
            var newValue = $(obj).parent().siblings(0).val();&lt;br /&gt;
            if(trim(newValue) == '') newValue = '(click to add text)';&lt;br /&gt;
      }&lt;br /&gt;
      else {&lt;br /&gt;
            newValue = cancel;&lt;br /&gt;
            if(trim(newValue) == '') newValue = '(click to add text)';&lt;br /&gt;
       }&lt;br /&gt;
            &lt;br /&gt;
      $(obj).parent().parent().after('&amp;lt;div class="edit"&amp;gt;' +  newValue +'&amp;lt;/div&amp;gt;').remove();&lt;br /&gt;
      setEditable();&lt;br /&gt;
}&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;That's it.  You can actually make an ajax request and send this data to the server for persistence.  We will see &lt;br /&gt;
that in an another post.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/rajeshpillai/aggbug/136550.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rajesh Pillai</dc:creator>
            <guid>http://geekswithblogs.net/rajeshpillai/archive/2009/11/26/in-place-edit-with-jquery.aspx</guid>
            <pubDate>Thu, 26 Nov 2009 07:24:42 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/rajeshpillai/comments/136550.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/rajeshpillai/archive/2009/11/26/in-place-edit-with-jquery.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/rajeshpillai/comments/commentRss/136550.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/rajeshpillai/services/trackbacks/136550.aspx</trackback:ping>
        </item>
        <item>
            <title>ASP.NET Session Id getting lost</title>
            <link>http://geekswithblogs.net/rajeshpillai/archive/2009/11/25/asp.net-session-id-getting-lost.aspx</link>
            <description>&lt;div class="post-text"&gt;
&lt;p&gt;This typical problem is almost faced by all new developer working with asp.net.&lt;/p&gt;
&lt;p&gt;This behaviour is by design as ASP.NET tries to be efficient in storing sessions for users. Remember &lt;br /&gt;
unless you store anything in session the session id value keep changing.&lt;/p&gt;
&lt;p&gt;If you want to tell ASP.NET that you want it to track user sessions, you can do one of 2 things:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Store something in the session.&lt;/li&gt;
    &lt;li&gt;Simple handle the Session_Start event in your GLobal.asax. The presence of this method will &lt;br /&gt;
    tell ASP.NET to track sessions , even if there is no data in the session..&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;// NOTE: There is no need to add any thing to session if you are doing this...&lt;/p&gt;
&lt;p&gt;public void Session_Start(object sender, EventArgs e)&lt;br /&gt;
{&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;The related stackoverflow post can be read here &lt;a href="http://stackoverflow.com/questions/1533709/session-id-changing-randomly/1535573#1535573"&gt;&lt;br /&gt;
stackoverflow.com/questions/1533709/session-id-changing-randomly/1535573#1535573&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This behavior had caused me much worry in the past :)&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/rajeshpillai/aggbug/136549.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rajesh Pillai</dc:creator>
            <guid>http://geekswithblogs.net/rajeshpillai/archive/2009/11/25/asp.net-session-id-getting-lost.aspx</guid>
            <pubDate>Wed, 25 Nov 2009 12:55:31 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/rajeshpillai/comments/136549.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/rajeshpillai/archive/2009/11/25/asp.net-session-id-getting-lost.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/rajeshpillai/comments/commentRss/136549.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/rajeshpillai/services/trackbacks/136549.aspx</trackback:ping>
        </item>
    </channel>
</rss>
