<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Chakravarthy's Space : InteQ</title><link>http://msmvps.com/blogs/chakravarthy/archive/tags/InteQ/default.aspx</link><description>Tags: InteQ</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>C# 3.0 - What's New : {Properties}-Part2</title><link>http://msmvps.com/blogs/chakravarthy/archive/2007/10/12/c-3-0-what-s-new-properties-part2.aspx</link><pubDate>Fri, 12 Oct 2007 10:07:56 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1244258</guid><dc:creator>Chakravarthy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/chakravarthy/rsscomments.aspx?PostID=1244258</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/chakravarthy/commentapi.aspx?PostID=1244258</wfw:comment><comments>http://msmvps.com/blogs/chakravarthy/archive/2007/10/12/c-3-0-what-s-new-properties-part2.aspx#comments</comments><description>&lt;p&gt;Property of the class can be considered as the mechanism of accessing the private variables of the class. In other words, properties act as wrappers to the private variables. Though, the new feature related to this is not so great from the point of technology, but highly meaningful from the developer point of view. In a large class code, having many fields and exposed as Properties, it is really difficult to remember the private fields association with the respective definition of properties. The new feature of Properties in C# 3.0 language specification says that the developer doesn&amp;#39;t require to define the private variables that are associated with the respective properties. During the good olden days, we are used to the following coding mechanism to declare the property via a private variable.&lt;/p&gt;&lt;pre class="code"&gt;        &lt;span&gt;// The private Variable declaration
&lt;/span&gt;        &lt;span&gt;string&lt;/span&gt; strEmpName;

        &lt;span&gt;// Property Declaration
&lt;/span&gt;        &lt;span&gt;public&lt;/span&gt; &lt;span&gt;string&lt;/span&gt; EmployeeName
        {
            &lt;span&gt;get&lt;/span&gt; {
                &lt;span&gt;// Returning the value from the private variable
&lt;/span&gt;                &lt;span&gt;return&lt;/span&gt; strEmpName;
                }
            &lt;span&gt;set&lt;/span&gt; {
                &lt;span&gt;// Assigning the value to private Variable
&lt;/span&gt;                strEmpName = &lt;span&gt;value&lt;/span&gt;; 
                }
        }&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;But hence forth, by using the C# 3.0 version, we doesn&amp;#39;t require to define as above but just as simple as mentioned below&lt;/p&gt;&lt;pre class="code"&gt;        &lt;span&gt;public&lt;/span&gt; &lt;span&gt;string&lt;/span&gt; EmployeeName { &lt;span&gt;get&lt;/span&gt;; &lt;span&gt;set&lt;/span&gt;; }&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;How simple is this, by this method we doesn&amp;#39;t require to remember which is property and which is a private variable. But bottom line remains the same as of the old tradition, the only thing that every one has to remember is that, there is no need to declare a private variable and association of the same with the exposed property. Beneath the code, the compiler creates a private variable for each property that you define as such. To justify, use any reflector to understand the emitted IL code and the Assembly signature. You will surprise to note that a separate private variable is associated by the compiler. &lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:68598688-ddf2-4ccc-b034-f69a8b021ad4" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/C#%20v3.0" rel="tag"&gt;C# v3.0&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1244258" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/C_2300_+3.0/default.aspx">C# 3.0</category><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/Hyderabad/default.aspx">Hyderabad</category><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/Tips/default.aspx">Tips</category><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/Code/default.aspx">Code</category><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/InteQ/default.aspx">InteQ</category></item><item><title>The importance of 'Return' keyword at JavaScript</title><link>http://msmvps.com/blogs/chakravarthy/archive/2007/09/15/the-importance-of-return-keyword-at-javascript.aspx</link><pubDate>Sat, 15 Sep 2007 12:26:53 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1198949</guid><dc:creator>Chakravarthy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/chakravarthy/rsscomments.aspx?PostID=1198949</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/chakravarthy/commentapi.aspx?PostID=1198949</wfw:comment><comments>http://msmvps.com/blogs/chakravarthy/archive/2007/09/15/the-importance-of-return-keyword-at-javascript.aspx#comments</comments><description>&lt;p&gt;Recently, while coding for a Text Field value padded with left zeros, realised the importance of the RETURN key word for the FUNCTION written in JavaScript. Before i mention the actual importance, let me describe you the situation.&lt;/p&gt; &lt;p&gt;Scenario: A Text box need to be padded with zeros and should have the length of 7 digits, even the data entered is less than 7.&lt;/p&gt; &lt;p&gt;Ex: When the key board input being 88, the text box should show &lt;strong&gt;00000&lt;/strong&gt;88. Note the ZEROs padded on left.&lt;/p&gt; &lt;p&gt;So, started with a JavaScript function as mentioned below&lt;/p&gt; &lt;blockquote&gt;&lt;pre class="code"&gt;&lt;span&gt;function&lt;/span&gt; PadZeros(x)
    {
        &lt;span&gt;var&lt;/span&gt; v = x.value;
        &lt;span&gt;while&lt;/span&gt;(v.length&amp;lt;7)
        {
            v = &lt;span&gt;&amp;#39;0&amp;#39;&lt;/span&gt; + v;
        }
        &lt;span&gt;var&lt;/span&gt; ss = document.getElementById(x.id);
        ss.value = v;
    }&lt;/pre&gt;&lt;/blockquote&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;After this, the text box is padding with ZEROs and the code is perfectly running. To allow this to code execute for any given text box, all you have to do is, add the ATTRIBUTE to that text box. And while adding keep one thing in mind that, we would be calling this function on BLUR, ie., LOST FOCUS of the text box. The code is as mentioned below.&lt;/p&gt;&lt;pre class="code"&gt;            &lt;span&gt;this&lt;/span&gt;.txtPCode.Attributes.Add(&lt;span&gt;&amp;quot;onblur&amp;quot;&lt;/span&gt;, &lt;span&gt;&amp;quot;PadZeros(this);&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Please note the &amp;#39;this&amp;#39; keyword. The usage of &amp;#39;this&amp;#39; keyword has many possibilities. Let me see that, one day will post where the &amp;#39;this&amp;#39; keyword is used and their context. And also note that, neither the function is returning any value nor the text box is added with the code that handles the output of the function. Will come to that in short.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Every thing is working perfectly well and going on smooth. But suddenly, i realised that the text box is just padding ZEROs when there is no Input. I see all ZEROs in the text box as &lt;strong&gt;0000000&lt;/strong&gt;. Then came the real trick to the function.&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class="code"&gt;&lt;span&gt;function&lt;/span&gt; PadZeros(x)
    {
        &lt;span&gt;var&lt;/span&gt; v = x.value;
        &lt;span&gt;if&lt;/span&gt;(v.length == 0)
        {
            &lt;span&gt;var&lt;/span&gt; vTe = document.getElementById(x.id);
            vTe.focus();
            alert(&lt;span&gt;&amp;#39;Please enter Provider Code .. &amp;#39;&lt;/span&gt;);
        }
        &lt;span&gt;while&lt;/span&gt;(v.length&amp;lt;7)
        {
            v = &lt;span&gt;&amp;#39;0&amp;#39;&lt;/span&gt; + v;
        }
        &lt;span&gt;var&lt;/span&gt; ss = document.getElementById(x.id);
        ss.value = v;
    }&lt;/pre&gt;&lt;/blockquote&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;What do you see here is the mechanism to set the focus back to the text box. Great... but that even is not solving my purpose of leaving the text box blank when there is no input. This function is still adding ZEROs to no input and showing all ZEROs. Then came the purpose of the &lt;strong&gt;&lt;font color="#0080ff"&gt;&amp;#39;return&amp;#39;&lt;/font&gt;&lt;/strong&gt; keyword. The entire requirement is simply solved by this keyword. All i&amp;#39;ve done is.. changed the code as mentioned below.&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class="code"&gt;&lt;span&gt;function&lt;/span&gt; PadZeros(x)
    {
        &lt;span&gt;var&lt;/span&gt; v = x.value;
        &lt;span&gt;if&lt;/span&gt;(v.length == 0)
        {
            &lt;span&gt;var&lt;/span&gt; vTe = document.getElementById(x.id);
            vTe.focus();
            alert(&lt;span&gt;&amp;#39;Please enter Provider Code .. &amp;#39;&lt;/span&gt;);
            &lt;span&gt;return&lt;/span&gt; &lt;span&gt;false&lt;/span&gt;;
        }
        &lt;span&gt;while&lt;/span&gt;(v.length&amp;lt;7)
        {
            v = &lt;span&gt;&amp;#39;0&amp;#39;&lt;/span&gt; + v;
        }
        &lt;span&gt;var&lt;/span&gt; ss = document.getElementById(x.id);
        ss.value = v;
        &lt;span&gt;return&lt;/span&gt; &lt;span&gt;true&lt;/span&gt;;
    }&lt;/pre&gt;&lt;/blockquote&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;At the code behind added &amp;#39;return&amp;#39; as shown here &lt;/p&gt;&lt;pre class="code"&gt;            &lt;span&gt;this&lt;/span&gt;.txtPCode.Attributes.Add(&lt;span&gt;&amp;quot;onblur&amp;quot;&lt;/span&gt;, &lt;span&gt;&amp;quot;return PadZeros(this);&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;That&amp;#39;s all.. hoollaa... What do you say ?&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a8c92c9f-3426-4b59-949b-0a4912605601" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/JavaScript" rel="tag"&gt;JavaScript&lt;/a&gt;, &lt;a href="http://technorati.com/tags/PadZeros" rel="tag"&gt;PadZeros&lt;/a&gt;, &lt;a href="http://technorati.com/tags/return" rel="tag"&gt;return&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1198949" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/First/default.aspx">First</category><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/Hyderabad/default.aspx">Hyderabad</category><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/Tips/default.aspx">Tips</category><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/Code/default.aspx">Code</category><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/InteQ/default.aspx">InteQ</category><category domain="http://msmvps.com/blogs/chakravarthy/archive/tags/JavaScript/default.aspx">JavaScript</category></item></channel></rss>