.NET Tips & Tricks Community Every .NET practitioner has a trick up in their sleeve. This is the place to share it with other .NET people. http://dotnettipoftheday.org/community http://backend.userland.com/rss RSS.NET: http://www.rssdotnet.com/ .net tip <p>.net tip</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">tiper</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mMxPOs1tGcY:6RZ2ZgG8mr4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mMxPOs1tGcY:6RZ2ZgG8mr4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mMxPOs1tGcY:6RZ2ZgG8mr4:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mMxPOs1tGcY:6RZ2ZgG8mr4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mMxPOs1tGcY:6RZ2ZgG8mr4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mMxPOs1tGcY:6RZ2ZgG8mr4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mMxPOs1tGcY:6RZ2ZgG8mr4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mMxPOs1tGcY:6RZ2ZgG8mr4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mMxPOs1tGcY:6RZ2ZgG8mr4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mMxPOs1tGcY:6RZ2ZgG8mr4:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/mMxPOs1tGcY" height="1" width="1"/> http://dotnettipoftheday.org/tips/net-tip.aspx Wed, 17 Feb 2010 09:10:16 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=net-tip Using Progressbar in a Class <p>You sometimes need to send a progress report to the user on the status of a particular function. Ex.&nbsp;when inserting records etc.</p> <p>// FROM YOUR FORM</p> <p>private void button1_Click(<span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">object</span></span><span style="font-size: x-small;"> sender, </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">EventArgs</span></span><span style="font-size: x-small;"> e)</span></p> <p><span style="font-size: x-small;">{</span></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yourclass.updatedb({"One","Two","Three"},this.ProgressBar1);</p> <p><span style="font-size: x-small;">}</span></p> <p>// INSIDE YOUR CLASS</p> <p>public string updatedb(string[] values,System.Windows.Forms.Progressbar pb)</p> <p>{</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Maximum = values.Length();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(string v in values)</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _insertdb(v); // CALL THE UPATE DB METHOD</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Value ++; // UPDATE PROGRESSBAR</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>}</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.google.com" style="font-weight:bold">Paul</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=N1MVNaNPPuA:F0TfVUFPtkI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=N1MVNaNPPuA:F0TfVUFPtkI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=N1MVNaNPPuA:F0TfVUFPtkI:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=N1MVNaNPPuA:F0TfVUFPtkI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=N1MVNaNPPuA:F0TfVUFPtkI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=N1MVNaNPPuA:F0TfVUFPtkI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=N1MVNaNPPuA:F0TfVUFPtkI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=N1MVNaNPPuA:F0TfVUFPtkI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=N1MVNaNPPuA:F0TfVUFPtkI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=N1MVNaNPPuA:F0TfVUFPtkI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/N1MVNaNPPuA" height="1" width="1"/> http://dotnettipoftheday.org/tips/using-progressbar-in-a-class4.aspx Mon, 23 Nov 2009 15:33:55 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=using-progressbar-in-a-class4 Using Progressbar in a Class <p>You sometimes need to send a progress report to the user on the status of a particular function. Ex.&nbsp;when inserting records etc.</p> <p>// FROM YOUR FORM</p> <p>private void button1_Click(<span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">object</span></span><span style="font-size: x-small;"> sender, </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">EventArgs</span></span><span style="font-size: x-small;"> e)</span></p> <p><span style="font-size: x-small;">{</span></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yourclass.updatedb({"One","Two","Three"},this.ProgressBar1);</p> <p><span style="font-size: x-small;">}</span></p> <p>// INSIDE YOUR CLASS</p> <p>public string updatedb(string[] values,System.Windows.Forms.Progressbar pb)</p> <p>{</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Maximum = values.Length();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(string v in values)</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _insertdb(v); // CALL THE UPATE DB METHOD</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Value ++; // UPDATE PROGRESSBAR</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>}</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.google.com" style="font-weight:bold">Paul</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u201tnNrsQY:g6MMTGCxCh4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=u201tnNrsQY:g6MMTGCxCh4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u201tnNrsQY:g6MMTGCxCh4:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u201tnNrsQY:g6MMTGCxCh4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=u201tnNrsQY:g6MMTGCxCh4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u201tnNrsQY:g6MMTGCxCh4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=u201tnNrsQY:g6MMTGCxCh4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u201tnNrsQY:g6MMTGCxCh4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u201tnNrsQY:g6MMTGCxCh4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=u201tnNrsQY:g6MMTGCxCh4:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/u201tnNrsQY" height="1" width="1"/> http://dotnettipoftheday.org/tips/using-progressbar-in-a-class3.aspx Mon, 23 Nov 2009 15:33:13 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=using-progressbar-in-a-class3 Using Progressbar in a Class <p>You sometimes need to send a progress report to the user on the status of a particular function. Ex.&nbsp;when inserting records etc.</p> <p>// FROM YOUR FORM</p> <p>private void button1_Click(<span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">object</span></span><span style="font-size: x-small;"> sender, </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">EventArgs</span></span><span style="font-size: x-small;"> e)</span></p> <p><span style="font-size: x-small;">{</span></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yourclass.updatedb({"One","Two","Three"},this.ProgressBar1)</p> <p><span style="font-size: x-small;">}</span></p> <p>// INSIDE YOUR CLASS</p> <p>public string updatedb(string[] values,System.Windows.Forms.Progressbar pb)</p> <p>{</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Maximum = values.Length();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(string v in values)</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _insertdb(v); // CALL THE UPATE DB METHOD</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Value ++;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>}</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.google.com" style="font-weight:bold">Paul</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JP2mHiRB254:EwvtHktlKgw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JP2mHiRB254:EwvtHktlKgw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JP2mHiRB254:EwvtHktlKgw:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JP2mHiRB254:EwvtHktlKgw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JP2mHiRB254:EwvtHktlKgw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JP2mHiRB254:EwvtHktlKgw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JP2mHiRB254:EwvtHktlKgw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JP2mHiRB254:EwvtHktlKgw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JP2mHiRB254:EwvtHktlKgw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JP2mHiRB254:EwvtHktlKgw:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/JP2mHiRB254" height="1" width="1"/> http://dotnettipoftheday.org/tips/using-progressbar-in-a-class2.aspx Mon, 23 Nov 2009 15:32:08 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=using-progressbar-in-a-class2 Using Progressbar in a Class <p>You sometimes need to send a progress report to the user on the status of a particular function. Ex.&nbsp;when inserting records etc.</p> <p>// FROM YOUR FORM</p> <p>private void button1_Click(<span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">object</span></span><span style="font-size: x-small;"> sender, </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">EventArgs</span></span><span style="font-size: x-small;"> e)</span></p> <p><span style="font-size: x-small;">{</span></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yourclass.updatedb({"One","Two","Three"},this.ProgressBar1)</p> <p><span style="font-size: x-small;">}</span></p> <p>// INSIDE YOUR CLASS</p> <p>public string updatedb(string[] values,System.Windows.Forms.Progressbar pb)</p> <p>{</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Maximum = values.Length();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(string v in values)</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _insertdb(v); // CALL THE UPATE DB METHOD</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Value ++;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>}</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.google.com" style="font-weight:bold">Paul</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ykkW-GsyAk4:mfKOmI6nE6Y:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ykkW-GsyAk4:mfKOmI6nE6Y:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ykkW-GsyAk4:mfKOmI6nE6Y:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ykkW-GsyAk4:mfKOmI6nE6Y:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ykkW-GsyAk4:mfKOmI6nE6Y:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ykkW-GsyAk4:mfKOmI6nE6Y:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ykkW-GsyAk4:mfKOmI6nE6Y:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ykkW-GsyAk4:mfKOmI6nE6Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ykkW-GsyAk4:mfKOmI6nE6Y:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ykkW-GsyAk4:mfKOmI6nE6Y:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/ykkW-GsyAk4" height="1" width="1"/> http://dotnettipoftheday.org/tips/using-progressbar-in-a-class1.aspx Mon, 23 Nov 2009 15:31:02 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=using-progressbar-in-a-class1 Using Progressbar in a Class <p>You sometimes need to send a progress report to the user on the status of a particular function. Ex.&nbsp;when inserting records etc.</p> <p>// FROM YOUR FORM</p> <p>private void button1_Click(<span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">object</span></span><span style="font-size: x-small;"> sender, </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">EventArgs</span></span><span style="font-size: x-small;"> e)</span></p> <p><span style="font-size: x-small;">{</span></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yourclass.updatedb({"One","Two","Three"},this.ProgressBar1)</p> <p><span style="font-size: x-small;">}</span></p> <p>// INSIDE YOUR CLASS</p> <p>public string updatedb(string[] values,System.Windows.Forms.Progressbar pb)</p> <p>{</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Maximum = values.Length();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(string v in values)</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _insertdb(v); // CALL THE UPATE DB METHOD</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pb.Value ++;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>}</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.google.com" style="font-weight:bold">Paul</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y05dZzDZZl8:UuHnJ72eERc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Y05dZzDZZl8:UuHnJ72eERc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y05dZzDZZl8:UuHnJ72eERc:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y05dZzDZZl8:UuHnJ72eERc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Y05dZzDZZl8:UuHnJ72eERc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y05dZzDZZl8:UuHnJ72eERc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Y05dZzDZZl8:UuHnJ72eERc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y05dZzDZZl8:UuHnJ72eERc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y05dZzDZZl8:UuHnJ72eERc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Y05dZzDZZl8:UuHnJ72eERc:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/Y05dZzDZZl8" height="1" width="1"/> http://dotnettipoftheday.org/tips/using-progressbar-in-a-class.aspx Mon, 23 Nov 2009 15:30:46 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=using-progressbar-in-a-class Use delegates to utilize a callback pattern <p>Essentially delegates are function pointers (which is a concept used in languages like C/C++). They are also a class in the .net programming framework (System.Delegate). It is an abstract class and its sealed; meaning you cannot inherit it. Delegates are object oriented, type-safe and secure.</p> <p>Any method that matches the delegate's signature, which consists of the return type and parameters, can be assigned to the delegate. This makes is possible to programmatically change method calls, and also plug new code into existing classes. As long as you know the delegate's signature, you can assign your own delegated method.</p> <p>Asynchronous patterns of code execution mainly employ the callback pattern. The callback function will execute once the asynchronous task completes. Developers mainly utilize this idea so that the end-users get the benefit of executing a followup routine (post asynchronous operation), but the developer need not know what that routine is or what it does. However the developer has to ensure that that routine (which is a method) has a signature that the end users specify.</p> <p>Take the example of the <strong>FileStream</strong> class in the <strong>System.IO</strong> namespace. It is mainly used for I/O. It has methods like BeginRead() and BeginWrite(); they are asynchronous versions of Read() and Write() respectively. They execute on a different thread.</p> <p>If you examine the prototype of the first method you would find the third argument (<strong>AsyncCallback</strong> <em>userCallback</em>) is actually a delegate. And, it expects a method whose return type is <strong>void</strong> and takes one argument of type <strong>IAsyncResult</strong>.</p> <div style="font-family:Courier New; font-size:10pt; color:#000000"> <p style="margin: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span> System.IAsyncResult BeginRead(<span style="color: #0000ff;">byte</span>[ ] array, <span style="color: #0000ff;">int</span> offset, <span style="color: #0000ff;">int</span> numBytes, System.AsyncCallback userCallback, <span style="color: #0000ff;">object</span> stateObject)</p> </div> <p>The declaration for AsyncCallback is:</p> <div style="font-family:Courier New; font-size:10pt; color:#000000"> <p style="margin: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">delegate</span> <span style="color: #0000ff;">void</span> AsyncCallback(System.IAsyncResult ar)</p> </div> <p>The BeginRead() method returns a value of type IAsyncResult. If you want to wait for an asynchronous read-operation to end, you have to call <strong>EndRead()</strong> and pass the corresponding IAsyncResult value.</p> <p>On a general note those classes which do some operation asynchronously have their corresponding Begin and End methods. Keep exploring to find out.</p> <p>Happy programming. (and a happy new 2009). ;)</p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><a href="http://deostroll.spaces.live.com/default.aspx" style="font-weight:bold">deostroll</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y6ZwWTnLVLI:MWNMKVnCJpw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Y6ZwWTnLVLI:MWNMKVnCJpw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y6ZwWTnLVLI:MWNMKVnCJpw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Y6ZwWTnLVLI:MWNMKVnCJpw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y6ZwWTnLVLI:MWNMKVnCJpw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Y6ZwWTnLVLI:MWNMKVnCJpw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y6ZwWTnLVLI:MWNMKVnCJpw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Y6ZwWTnLVLI:MWNMKVnCJpw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Y6ZwWTnLVLI:MWNMKVnCJpw:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/Y6ZwWTnLVLI" height="1" width="1"/> http://dotnettipoftheday.org/tips/use-delegates-to-utilize-a-callback-pattern.aspx Thu, 01 Jan 2009 12:26:47 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=use-delegates-to-utilize-a-callback-pattern Format the current document in Visual Studio <p>Press ctrl +E, D, It will apply the format(like indent, spacing etc)&nbsp; to whole current document.</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Yaseen</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nmSlmsHIf0Y:FzHA2b4VtAM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=nmSlmsHIf0Y:FzHA2b4VtAM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nmSlmsHIf0Y:FzHA2b4VtAM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=nmSlmsHIf0Y:FzHA2b4VtAM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nmSlmsHIf0Y:FzHA2b4VtAM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=nmSlmsHIf0Y:FzHA2b4VtAM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nmSlmsHIf0Y:FzHA2b4VtAM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nmSlmsHIf0Y:FzHA2b4VtAM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=nmSlmsHIf0Y:FzHA2b4VtAM:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/nmSlmsHIf0Y" height="1" width="1"/> http://dotnettipoftheday.org/tips/format-the-current-document-in-visual-studio.aspx Wed, 26 Nov 2008 17:27:53 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=format-the-current-document-in-visual-studio WPF Equivalent for ListView.GetItemAt(e.X,e.Y) <p>FrameworkElement framework = e.OriginalSource as FrameworkElement;</p> <p>ListViewItem lvi = Lstview.ItemContainerGenerator.ContainerFromItem(fe.DataContext) as ListViewItem;</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Renuka</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=GgBBEG4JGgQ:PXSyf9Slja8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=GgBBEG4JGgQ:PXSyf9Slja8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=GgBBEG4JGgQ:PXSyf9Slja8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=GgBBEG4JGgQ:PXSyf9Slja8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=GgBBEG4JGgQ:PXSyf9Slja8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=GgBBEG4JGgQ:PXSyf9Slja8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=GgBBEG4JGgQ:PXSyf9Slja8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=GgBBEG4JGgQ:PXSyf9Slja8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=GgBBEG4JGgQ:PXSyf9Slja8:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/GgBBEG4JGgQ" height="1" width="1"/> http://dotnettipoftheday.org/tips/wpf-equivalent-for-listviewgetitematexey.aspx Tue, 16 Sep 2008 16:57:51 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=wpf-equivalent-for-listviewgetitematexey Generating artificial phone numbers (in North America) <p>Having worked for a company that developed phone fraud detection software in a previous life, I was familiar with the North American Numbering Plan described in <a href="http://en.wikipedia.org/wiki/North_American_Numbering_Plan" target="_blank">Wikipedia</a>. Several times I&rsquo;ve had a need to create artificial phone numbers.</p> <p>Below is an algorithm that will handle most if not all of these numbers.</p> <div style="BORDER-RIGHT: #a52a2a 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #a52a2a 1px solid; PADDING-LEFT: 5px; FONT-SIZE: 10pt; BACKGROUND: #f5f5dc; PADDING-BOTTOM: 5px; BORDER-LEFT: #a52a2a 1px solid; COLOR: black; PADDING-TOP: 5px; BORDER-BOTTOM: #a52a2a 1px solid; FONT-FAMILY: Courier New"> <p style="MARGIN: 0px"><span style="color: blue;">private</span> <span style="color: blue;">string</span> GetRandomPhone()</p> <p style="MARGIN: 0px">{</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: green;">// Generate a NANP compliant phone number (look in wikipedia under North American Numbering Plan)</span></p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue;">var</span> rnd = <span style="color: blue;">new</span> <span style="color: #2b91af;">Random</span>();</p> <p style="MARGIN: 0px">&nbsp;</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: green;">// A number consists of 3 parts: NPA Nxx Station</span></p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: green;">// NPA (Numbering Plan Area code) = [2-9][0-8][0-9] </span></p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: green;">// Exclude common toll and toll-free numbers</span></p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue;">int</span> npa = 0;</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue;">while</span> (npa == 0 || npa == 800 || npa == 877 || npa == 888 || npa == 900)</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; {</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; npa = rnd.Next(2, 9) * 100 + rnd.Next(0, 8) * 10 + rnd.Next(9);</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; }</p> <p style="MARGIN: 0px">&nbsp;</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: green;">// NXX (Central Office or Exchange code) = [2-9][0-9][0-9]</span></p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: green;">// Exception the second digits may not be 11</span></p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue;">int</span> nxx = 0;</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue;">while</span> (nxx == 0 || nxx % 100 == 11)</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; {</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nxx = rnd.Next(2, 9)*100 + rnd.Next(99);</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; }</p> <p style="MARGIN: 0px">&nbsp;</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: green;">// Station code = [0-9][0-9][0-9][0-9]</span></p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: green;">// When 555 is the NXX the number 100-199 are reserved or fictional numbers)</span></p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue;">int</span> station = 0;</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue;">while</span> (station == 0 || (nxx == 555 &amp;&amp; station &gt; 99 &amp;&amp; station &lt; 200))</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; {</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; station = rnd.Next(9999);</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; }</p> <p style="MARGIN: 0px">&nbsp;</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue;">const</span> <span style="color: blue;">string</span> format = <span style="color: #a31515;">"({0:000}) {1:000}-{2:0000}"</span>;</p> <p style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> <span style="color: blue;">string</span>.Format(format, npa, nxx, station);</p> <p style="MARGIN: 0px">}</p> </div> <p><!--EndFragment--></p> <p><strong></strong>&nbsp;</p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><a href="John Theisen" style="font-weight:bold">jtheisen</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=B7xlrV5uhWw:6scDS4pqQnI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=B7xlrV5uhWw:6scDS4pqQnI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=B7xlrV5uhWw:6scDS4pqQnI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=B7xlrV5uhWw:6scDS4pqQnI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=B7xlrV5uhWw:6scDS4pqQnI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=B7xlrV5uhWw:6scDS4pqQnI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=B7xlrV5uhWw:6scDS4pqQnI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=B7xlrV5uhWw:6scDS4pqQnI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=B7xlrV5uhWw:6scDS4pqQnI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/B7xlrV5uhWw" height="1" width="1"/> http://dotnettipoftheday.org/tips/generating-artificial-phone-numbers-in-north-america.aspx Thu, 28 Aug 2008 23:22:53 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=generating-artificial-phone-numbers-in-north-america LINQ to XML method chaining <p>First, I have to say that I really love using LINQ to SQL and LINQ&nbsp;to Objects. I wasn&rsquo;t able to say the same thing about LINQ to XML until recently.</p> <p>Here&rsquo;s an XML document that I&rsquo;ll use for this example:</p> <div style="border: 1px solid #a52a2a; padding: 5px; background: #f5f5dc none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Courier New;"> <p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">Zoo</span><span style="color: blue;">&gt;</span></p> <p style="margin: 0px;"><span style="color: blue;">&nbsp; &lt;</span><span style="color: #a31515;">Animals</span><span style="color: blue;">&gt;</span></p> <p style="margin: 0px;"><span style="color: blue;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515;">Animal</span><span style="color: blue;"> </span><span style="color: red;">species</span><span style="color: blue;">=</span>"<span style="color: blue;">monkey</span>"<span style="color: blue;">&gt;</span>George<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Animal</span><span style="color: blue;">&gt;</span></p> <p style="margin: 0px;"><span style="color: blue;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515;">Animal</span><span style="color: blue;"> </span><span style="color: red;">species</span><span style="color: blue;">=</span>"<span style="color: blue;">monkey</span>"<span style="color: blue;">&gt;</span>Zanzi<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Animal</span><span style="color: blue;">&gt;</span></p> <p style="margin: 0px;"><span style="color: blue;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515;">Animal</span><span style="color: blue;"> </span><span style="color: red;">species</span><span style="color: blue;">=</span>"<span style="color: blue;">panda</span>"<span style="color: blue;">&gt;</span>Long-Long<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Animal</span><span style="color: blue;">&gt;</span></p> <p style="margin: 0px;"><span style="color: blue;">&nbsp; &lt;/</span><span style="color: #a31515;">Animals</span><span style="color: blue;">&gt;</span></p> <p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Zoo</span><span style="color: blue;">&gt;</span></p> </div> <p>I&rsquo;m very familiar with XPath expressions and if I wanted to find all of the panda&rsquo;s in the Zoo I could write an expression like:</p> <blockquote style="margin-right: 0px;" dir="ltr"> <p>/Zoo/Animals/Animal[@species=&rsquo;panda&rsquo;]</p> </blockquote> <p dir="ltr">So that works great and it would return to me the element containing &lsquo;Long-Long&rsquo;. Now for the LINQ to XML equivalant without using the XPath Extensions Method.</p> <div style="border: 1px solid #a52a2a; padding: 5px; background: #f5f5dc none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Courier New;"> <p style="margin: 0px;"><span style="color: blue;">var</span> panda = <span style="text-decoration: underline;"><span style="color: #ff0000;"><em>doc.Element(<span style="color: #a31515;">"Zoo"</span>)</em></span></span>.<span style="color: #ff0000;"><em><span style="text-decoration: underline;">Element(<span style="color: #a31515;">"Animals"</span>)</span></em></span>.Descendants(<span style="color: #a31515;">"Animal"</span>)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; .Where(e =&gt; e.<em><span style="text-decoration: underline;"><span style="color: #ff0000;">Attribute(<span style="color: #a31515;">"species"</span>)</span></span></em>.Value == <span style="color: #a31515;">"panda"</span>);</p> </div> <p><!--EndFragment--></p> <p dir="ltr">The problem is that all of the italic, underlined and in red text (i.e. the .Element() and .Attribute())&nbsp;methods can return null. So, I went from a clear and consise XPath expression to a less readable LINQ call that I should be checking for null for each of the Element and Attribute calls. Hmmm, not good.</p> <p dir="ltr">Fortunately, .NET 3.5 introduces Extension Methods that allow us to extend existing classes with new Methods. Here&rsquo;s the class that I came up with:</p> <div style="border: 1px solid #a52a2a; padding: 5px; background: #f5f5dc none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Courier New;"> <p style="margin: 0px;"><span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">XmlExtensions</span></p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">XElement</span> SafeElement(<span style="color: blue;">this</span> <span style="color: #2b91af;">XContainer</span> container, <span style="color: blue;">string</span> name)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> container.Element(name) ?? <span style="color: blue;">new</span> <span style="color: #2b91af;">XElement</span>(name);</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">XAttribute</span> SafeAttribute(<span style="color: blue;">this</span> <span style="color: #2b91af;">XElement</span> element, <span style="color: blue;">string</span> name)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> element.Attribute(name) ?? <span style="color: blue;">new</span> <span style="color: #2b91af;">XAttribute</span>(name, <span style="color: #a31515;">""</span>);</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">}</p> </div> <p><!--EndFragment--></p> <p>For an introduction on Extension Methods, read this blog entry from ScottGu <a href="http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx" target="_blank">here</a>. Note that there are three indicators that this is an extension method:</p> <ol> <li>The class has been declared static.</li> <li>Each of the extension methods is also static.</li> <li>There is a &ldquo;this&rdquo; keyword before the first parameter argument.</li> </ol> <p>The &lsquo;SafeElement&rsquo; method is extending the XContainer class and the &lsquo;SafeAttribute&rsquo; method is extending the XElement class.</p> <p>We these are used in our example we get:</p> <div style="border: 1px solid #a52a2a; padding: 5px; background: #f5f5dc none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Courier New;"> <p style="margin: 0px;"><span style="color: blue;">var</span> panda = doc.SafeElement(<span style="color: #a31515;">"Zoo"</span>).SafeElement(<span style="color: #a31515;">"Animals"</span>).Descendants(<span style="color: #a31515;">"Animal"</span>)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; .Where(e =&gt; e.SafeAttribute(<span style="color: #a31515;">"species"</span>).Value == <span style="color: #a31515;">"panda"</span>);</p> </div> <p><!--EndFragment--></p> <p>If you are using <a href="http://www.jetbrains.com/resharper" target="_blank">Resharper</a>&nbsp;you will see the squiggles disappear from the expression now. So, how and why does this work and allow us to use expression chaining? Since we are guaranteed to get an either an XElement or XAttribute back from the respective calls, we won&rsquo;t blow up with a NullReferenceException. That&rsquo;s good. In addition, since we return an empty Element or Attribute, our other chained calls will fail cleanly, thus the Lamba Expression will not match any items if we had loaded a different XML document.</p> <p>&nbsp;</p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><a href="John Theisen" style="font-weight:bold">jtheisen</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8FnzzEy40lE:EWCfYF_Q3TI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=8FnzzEy40lE:EWCfYF_Q3TI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8FnzzEy40lE:EWCfYF_Q3TI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=8FnzzEy40lE:EWCfYF_Q3TI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8FnzzEy40lE:EWCfYF_Q3TI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=8FnzzEy40lE:EWCfYF_Q3TI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8FnzzEy40lE:EWCfYF_Q3TI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8FnzzEy40lE:EWCfYF_Q3TI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=8FnzzEy40lE:EWCfYF_Q3TI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/8FnzzEy40lE" height="1" width="1"/> http://dotnettipoftheday.org/tips/linq-to-xml-method-chaining1.aspx Wed, 27 Aug 2008 00:24:46 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=linq-to-xml-method-chaining1 Launching solution file from the command line <p>Before <a href="http://www.jetbrains.com/resharper" target="_blank">Resharper</a> came along and clutter my directories with files, I used tab-completion to launch my solution files from the command line using:</p> <blockquote> <p><span style="font-family: Courier New;">START MyApplication.sln</span></p> </blockquote> <p dir="ltr"><a href="http://www.flickr.com/photos/8061254@N07/2779638963/"><img src="http://static.flickr.com/3061/2779638963_01c6c4bd6a.jpg" border="0" alt="commandline" hspace="5" vspace="5" /></a></p> <p dir="ltr">But, with two other resharper files now preceeding the solution file I needed another way to launch the solutution file. Here&rsquo;s the script that I came up with:</p> <blockquote> <p dir="ltr"><span style="font-family: Courier New;">@<a href="http://technet.microsoft.com/en-us/library/cc756140.aspx" target="_blank">ECHO</a> OFF</span></p> <p dir="ltr"><span style="font-family: Courier New;"><a href="http://technet.microsoft.com/en-us/library/cc755694.aspx" target="_blank">FOR</a> %%n IN (*.sln) DO START %%n</span></p> </blockquote> <p dir="ltr">If you have more than one solution file in the same directory, this script is not for you, but that is not a likely scenario. I saved this file as sln.bat and put in the \windows\system32 directory, although any directory in your PATH will do.&nbsp;</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://dotnetbkm.blogspot.com/" style="font-weight:bold">John Theisen</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ls97tRiT0Ng:ar-XM0tgYMY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ls97tRiT0Ng:ar-XM0tgYMY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ls97tRiT0Ng:ar-XM0tgYMY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ls97tRiT0Ng:ar-XM0tgYMY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ls97tRiT0Ng:ar-XM0tgYMY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ls97tRiT0Ng:ar-XM0tgYMY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ls97tRiT0Ng:ar-XM0tgYMY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ls97tRiT0Ng:ar-XM0tgYMY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ls97tRiT0Ng:ar-XM0tgYMY:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/ls97tRiT0Ng" height="1" width="1"/> http://dotnettipoftheday.org/tips/launching-solution-file-from-the-command-line.aspx Wed, 20 Aug 2008 08:33:33 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=launching-solution-file-from-the-command-line Making your ASP.NET Ajax Webservice calls faster <p>An article talking about making ASP.NET Ajax Webservice calls faster by using a technique to divide the Ajax calls into several sub domains. The article includes a JavaScript class that acts like a manager for Ajax Webservice calls giving them several benefits. Its usage is transparent and you do not need to change your existing code. Any developer who uses ASP.NET Ajax Webservice calls should not miss this article.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://varjabedian.net" style="font-weight:bold">Ralph Varjabedian</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kH1pZiELPFQ:vkoPcxCr9Uo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=kH1pZiELPFQ:vkoPcxCr9Uo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kH1pZiELPFQ:vkoPcxCr9Uo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=kH1pZiELPFQ:vkoPcxCr9Uo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kH1pZiELPFQ:vkoPcxCr9Uo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=kH1pZiELPFQ:vkoPcxCr9Uo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kH1pZiELPFQ:vkoPcxCr9Uo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kH1pZiELPFQ:vkoPcxCr9Uo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=kH1pZiELPFQ:vkoPcxCr9Uo:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/kH1pZiELPFQ" height="1" width="1"/> http://dotnettipoftheday.org/tips/making-your-aspnet-ajax-webservice-calls-faster.aspx Tue, 12 Aug 2008 18:56:24 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=making-your-aspnet-ajax-webservice-calls-faster How to register a .NET Assembly without using gacutil <p>If&nbsp;the target machine does&nbsp;not have gacutil.exe (for example if SDK is not installed) doing a .NET script to do the same is very easy.</p> <p>- Add reference to System.EnterpriseServices assembly and</p> <pre class="c"><span style="color: #808080; font-style: italic;"><div style="font-family:Courier New; font-size:10pt; color:#000000"><p style="margin: 0px;"><span style="color: #0000ff;">using</span> System.EnterpriseServices.Internal; </p><p style="margin: 0px;">... </p><p style="margin: 0px;">Publish p = <span style="color: #0000ff;">new</span> Publish(); </p><p style="margin: 0px;"><span style="color: #008200;">// for GAC Installation </span></p><p style="margin: 0px;">p.GacInstall(file); <span style="color: #008200;">// for gac installation </span></p><p style="margin: 0px;">... </p><p style="margin: 0px;">p.GacRemove(file); <span style="color: #008200;">// for gac removing </span></p><p style="margin: 0px;">... </p><p style="margin: 0px;">p.RegisterAssembly(file); <span style="color: #008200;">// for registering assembly for interop </span></p><p style="margin: 0px;">... </p><p style="margin: 0px;">p.UnRegisterAssembly(file); <span style="color: #008200;">// to unregister assembly</span></p></div></span></pre> <p>Carefull thow on Vista you should probably try running the program as an Administrator</p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><span style="font-weight:bold">sharpoverride</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=MMeWd1CsYe4:94DYbdfZAuI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=MMeWd1CsYe4:94DYbdfZAuI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=MMeWd1CsYe4:94DYbdfZAuI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=MMeWd1CsYe4:94DYbdfZAuI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=MMeWd1CsYe4:94DYbdfZAuI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=MMeWd1CsYe4:94DYbdfZAuI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=MMeWd1CsYe4:94DYbdfZAuI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=MMeWd1CsYe4:94DYbdfZAuI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=MMeWd1CsYe4:94DYbdfZAuI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/MMeWd1CsYe4" height="1" width="1"/> http://dotnettipoftheday.org/tips/how-to-register-a-net-assembly-without-using-gacutil.aspx Wed, 09 Jul 2008 09:24:32 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=how-to-register-a-net-assembly-without-using-gacutil Why DotNetTipOfTheDay can lick my balls (a memo): <p>I think it is safe to say this website sucks ass.</p> <p>Practically two months without an update when people have been submitting things for you to post.</p> <p>I am pretty lazy when it comes to a lot of things, and up until today have kept your shitty RSS feed in my reader in hopes that you would actully update the site some day.</p> <p>But you suck and I hope your website bombs.&nbsp;</p> <p>Burn in hell.</p> <p>-thiswebsitesuck</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://dotnettipofthedayblowsass.com" style="font-weight:bold">thiswebsitesucks</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=io3jtC9Phek:3dRhonvZKi0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=io3jtC9Phek:3dRhonvZKi0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=io3jtC9Phek:3dRhonvZKi0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=io3jtC9Phek:3dRhonvZKi0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=io3jtC9Phek:3dRhonvZKi0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=io3jtC9Phek:3dRhonvZKi0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=io3jtC9Phek:3dRhonvZKi0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=io3jtC9Phek:3dRhonvZKi0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=io3jtC9Phek:3dRhonvZKi0:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/io3jtC9Phek" height="1" width="1"/> http://dotnettipoftheday.org/tips/why-dotnettipoftheday-can-lick-my-balls-a-memo1.aspx Thu, 03 Jul 2008 18:13:05 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=why-dotnettipoftheday-can-lick-my-balls-a-memo1 Fill datset without open connection <p>There is no need&nbsp;</p> <p>Connection.Open</p> <p>Before calling Method</p> <p>Adapter.Fill(Dataset)</p> <p><br />like</p> <p>&nbsp;public override DataSet getSMCommentedSubmission(string prodID, string salesID)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (SqlConnection cn = new SqlConnection(this.ConnectionString))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlCommand cmd = new SqlCommand("sp_WB_Submission", cn);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlDataAdapter adp = new SqlDataAdapter(cmd);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataSet dset = new DataSet();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.CommandType = CommandType.StoredProcedure;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@SqType", SqlDbType.Int).Value = 48;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@PubPlanID", SqlDbType.Int).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@TypeID", SqlDbType.Int).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@Title", SqlDbType.VarChar).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@CommentID", SqlDbType.Int).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@ThemeText", SqlDbType.VarChar).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@StorySynopsys", SqlDbType.VarChar).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@Status", SqlDbType.VarChar).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@Comments", SqlDbType.VarChar).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@TimeStamp", SqlDbType.SmallDateTime).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@PublisherID", SqlDbType.Int).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@PermissionType", SqlDbType.VarChar).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@Checked", SqlDbType.VarChar).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@SMStatus", SqlDbType.VarChar).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@PMStatus", SqlDbType.VarChar).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@ProductionManagerID", SqlDbType.VarChar).Value = prodID;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@SalesManagerID", SqlDbType.VarChar).Value = salesID;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@StoryID", SqlDbType.Int).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd.Parameters.Add("@Review", SqlDbType.Int).Value = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adp.Fill(dset);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return dset;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>&nbsp;</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Ajay</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hSMXjxvJT3c:vpOSWgKVuOE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=hSMXjxvJT3c:vpOSWgKVuOE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hSMXjxvJT3c:vpOSWgKVuOE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=hSMXjxvJT3c:vpOSWgKVuOE:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hSMXjxvJT3c:vpOSWgKVuOE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=hSMXjxvJT3c:vpOSWgKVuOE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hSMXjxvJT3c:vpOSWgKVuOE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hSMXjxvJT3c:vpOSWgKVuOE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=hSMXjxvJT3c:vpOSWgKVuOE:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/hSMXjxvJT3c" height="1" width="1"/> http://dotnettipoftheday.org/tips/fill-datset-without-open-connection1.aspx Wed, 11 Jun 2008 09:09:21 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=fill-datset-without-open-connection1 Never lock on a value type <p>When locking on a value type it gets boxed, meaning a new object instance is allocated and passed to the lock statement. Thus every time you lock on a value type, you're locking on a new object. Here is an example of&nbsp;<strong>bad</strong> code:</p> <div style="font-size: 10pt; background: white; color: black; font-family: Courier New;"> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">bool</span> flag = <span style="color: #0000ff;">false</span>;</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> Method1()</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">lock</span>(flag)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> </div> <p><!--EndFragment--></p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><span style="font-weight:bold">kostya.ly</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=g3-667hb52Y:NA_rHSz4S9s:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=g3-667hb52Y:NA_rHSz4S9s:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=g3-667hb52Y:NA_rHSz4S9s:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=g3-667hb52Y:NA_rHSz4S9s:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=g3-667hb52Y:NA_rHSz4S9s:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=g3-667hb52Y:NA_rHSz4S9s:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=g3-667hb52Y:NA_rHSz4S9s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=g3-667hb52Y:NA_rHSz4S9s:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=g3-667hb52Y:NA_rHSz4S9s:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/g3-667hb52Y" height="1" width="1"/> http://dotnettipoftheday.org/tips/never-lock-on-a-value-type.aspx Wed, 04 Jun 2008 23:01:26 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=never-lock-on-a-value-type need to use either “using” or explicitly close the connection if we use the datareader <p class="null"><span style="font-size: x-small; font-family: Arial;"><span style="font-size: 10pt; font-family: Arial;">We need to use either &ldquo;using&rdquo; or explicitly close the connection if we use the datareader.</span></span></p> <p class="null"><span style="font-size: x-small; font-family: Arial;"><span style="font-size: 10pt; font-family: Arial;">Otherwise, it will lead to Connection Pool error. See the underlined text below:</span></span></p> <p class="null" style="margin-bottom: 3.75pt; margin-left: 0in; margin-right: 0in; mso-margin-top-alt: 7.5pt;"><span style="font-size: xx-small; color: #000000; font-family: Verdana;"><span style="font-size: 8.5pt; color: #000000; font-family: Verdana;">&nbsp;</span></span></p> <p class="null" style="margin-bottom: 3.75pt; margin-left: 0in; margin-right: 0in; mso-margin-top-alt: 7.5pt;"><span style="font-size: xx-small; color: #000000; font-family: Verdana;"><span style="font-size: 8.5pt; color: #000000; font-family: Verdana;">However, there are other cases where it is unclear when to close the connection. An example is the <strong><span style="font-weight: bold;">ExecuteReader</span></strong> method. This method returns an object that implements the <strong><span style="font-weight: bold;">IDataReader</span></strong> interface. The <strong><span style="font-weight: bold;">Database</span></strong> base class has a default implementation that returns a <strong><span style="font-weight: bold;">DbDataReader</span></strong> object. <strong><span style="font-weight: bold;">DbDataReader</span></strong> objects are designed to read specific portions of the data as needed, which requires an open connection. In other words, it is unknown when the application no longer needs the <strong><span style="font-weight: bold;">DbDataReader</span></strong>. If the Data Access Application Block methods close the connection before returning the <strong><span style="font-weight: bold;">DbDataReader</span></strong>, the <strong><span style="font-weight: bold;">DbDataReader</span></strong> becomes useless to the client code. Instead, the <strong><span style="font-weight: bold;">DbDataReader</span></strong> methods indicate to the underlying ADO.NET call to automatically close the connection when the <strong><span style="font-weight: bold;">DbDataReader</span></strong> is finished. </span></span><span style="text-decoration: underline;"><span style="font-size: xx-small; color: #0000ff; font-family: Verdana;"><span style="font-size: 8.5pt; color: #0000ff; font-family: Verdana;">In this situation, it is considered a best practice for the application to ensure that the <strong><span style="font-weight: bold;">DbDataReader</span></strong> is closed in a timely fashion, either by explicitly closing the reader with the <strong><span style="font-weight: bold;">DbDataReader.close</span></strong> method or by forcing the disposal of the <strong><span style="font-weight: bold;">DbDataReader</span></strong>, which results in the <strong><span style="font-weight: bold;">Close</span></strong> method being called.</span></span></span></p> <p class="null" style="margin-bottom: 3.75pt; margin-left: 0in; margin-right: 0in; mso-margin-top-alt: 7.5pt;"><span style="text-decoration: underline;"><span style="font-size: xx-small; color: #0000ff; font-family: Verdana;"><span style="font-size: 8.5pt; color: #0000ff; font-family: Verdana;">The following code demonstrates a call to the <strong><span style="font-weight: bold;">ExecuteReader</span></strong> method. The <strong><span style="font-weight: bold;">using</span></strong> statement (<strong><span style="font-weight: bold;">Using</span></strong> in Visual Basic) ensures that the <strong><span style="font-weight: bold;">DbDataReader</span></strong> object is disposed, which closes the <strong><span style="font-weight: bold;">DbDataReader</span></strong> object.</span></span></span></p> <table class="MsoNormalTable" style="width: 98.9%;" border="0" cellspacing="0" cellpadding="0" width="98%"> <tbody> <tr> <td style="border-right: medium none; padding-right: 3.75pt; border-top: medium none; padding-left: 3.75pt; background: #efeff7; padding-bottom: 0in; border-left: medium none; padding-top: 0in; border-bottom: #c8cdde 1pt solid;" valign="top" bgcolor="#efeff7"> <p class="null" style="margin-bottom: 3.75pt; margin-left: 0in; margin-right: 0in; mso-margin-top-alt: 3.75pt;"><strong><span style="font-size: medium; color: #000066; font-family: Verdana;"> <p class="null" style="margin-bottom: 3.75pt; margin-left: 0in; margin-right: 0in; mso-margin-top-alt: 3.75pt;"><strong><span style="font-size: medium; color: #000066; font-family: Verdana;"><span style="font-weight: bold; font-size: 13.5pt; color: #000066; font-family: Verdana;"><span>[C#]&nbsp;</span></span></span></strong></p> </span></strong></p> </td> <td style="border-right: medium none; padding-right: 3.75pt; border-top: medium none; padding-left: 3.75pt; background: #efeff7; padding-bottom: 0in; border-left: medium none; padding-top: 0in; border-bottom: #c8cdde 1pt solid;" valign="top" bgcolor="#efeff7"> <p class="null" style="margin-bottom: 3.75pt; margin-left: 0in; margin-right: 0in; mso-margin-top-alt: 3.75pt;">&nbsp;</p> </td> </tr> <tr> <td style="border-right: medium none; padding-right: 3.75pt; border-top: white 1pt solid; padding-left: 3.75pt; background: #f7f7ff; padding-bottom: 0in; border-left: medium none; padding-top: 3.75pt; border-bottom: #d5d5d3 1pt solid;" colspan="2" valign="top" bgcolor="#f7f7ff"> <p class="null" style="margin-bottom: 0pt; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: 0in;"><span style="font-size: medium; color: #000066; font-family: Courier New;"><span style="font-size: 14pt; color: #000066; font-family: 'Courier New';">Database db = DatabaseFactory.CreateDatabase();</span></span></p> <p class="null" style="margin-bottom: 0pt; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: 0in;"><span style="font-size: medium; color: #000066; font-family: Courier New;"><span style="font-size: 14pt; color: #000066; font-family: 'Courier New';">&nbsp;</span></span></p> <p class="null" style="margin-bottom: 0pt; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: 0in;"><span style="font-size: medium; color: #000066; font-family: Courier New;"><span style="font-size: 14pt; color: #000066; font-family: 'Courier New';">DbCommand dbCommand = db.GetSqlStringCommand("Select Name, Address From Customers");</span></span></p> <p class="null" style="margin-bottom: 0pt; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: 0in;"><span style="font-size: medium; color: #000066; font-family: Courier New;"><span style="font-size: 14pt; color: #000066; font-family: 'Courier New';">using (IDataReader dataReader = db.ExecuteReader(dbCommand))</span></span></p> <p class="null" style="margin-bottom: 0pt; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: 0in;"><span style="font-size: medium; color: #000066; font-family: Courier New;"><span style="font-size: 14pt; color: #000066; font-family: 'Courier New';">{</span></span></p> <p class="null" style="margin-bottom: 0pt; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: 0in;"><span style="font-size: medium; color: #000066; font-family: Courier New;"><span style="font-size: 14pt; color: #000066; font-family: 'Courier New';">// Process results</span></span></p> <p class="null" style="margin-bottom: 0pt; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: 0in;"><span style="font-size: medium; color: #000066; font-family: Courier New;"><span style="font-size: 14pt; color: #000066; font-family: 'Courier New';">} </span></span></p> </td> </tr> </tbody> </table> <p class="null"><span style="font-size: x-small; font-family: Arial;"></span></p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><span style="font-weight:bold">saisuchir</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u5kOn7NLWBI:z1otk-oq83s:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=u5kOn7NLWBI:z1otk-oq83s:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u5kOn7NLWBI:z1otk-oq83s:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=u5kOn7NLWBI:z1otk-oq83s:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u5kOn7NLWBI:z1otk-oq83s:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=u5kOn7NLWBI:z1otk-oq83s:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u5kOn7NLWBI:z1otk-oq83s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=u5kOn7NLWBI:z1otk-oq83s:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=u5kOn7NLWBI:z1otk-oq83s:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/u5kOn7NLWBI" height="1" width="1"/> http://dotnettipoftheday.org/tips/need-to-use-either-using-or-explicitly-close-the-connection-if-we-use-.aspx Thu, 15 May 2008 16:49:14 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=need-to-use-either-using-or-explicitly-close-the-connection-if-we-use- BrowsableAttribute <p>when u are creating a control, and u decides that a property or a event should not be displayed in property window.</p> <p>System.ComponentModel.BrowsableAttribute is there for you, to do the above.</p> <p>Eg:</p> <p>private string text;</p> <p>[Browsable(false)]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; True is default<br />&nbsp;public string Text<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return text;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text = value;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp; }</p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><span style="font-weight:bold">dhanaid</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E7vcdNpCkQ0:X__cx34E41w:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=E7vcdNpCkQ0:X__cx34E41w:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E7vcdNpCkQ0:X__cx34E41w:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=E7vcdNpCkQ0:X__cx34E41w:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E7vcdNpCkQ0:X__cx34E41w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=E7vcdNpCkQ0:X__cx34E41w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E7vcdNpCkQ0:X__cx34E41w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E7vcdNpCkQ0:X__cx34E41w:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=E7vcdNpCkQ0:X__cx34E41w:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/E7vcdNpCkQ0" height="1" width="1"/> http://dotnettipoftheday.org/tips/browsableattribute.aspx Tue, 13 May 2008 15:43:13 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=browsableattribute Get rid of unused usings <p>In a Visual Studio 2008 source window,&nbsp;right-click and&nbsp;select&nbsp;<strong>Organize Usings</strong> | <strong>Remove Unused Usings</strong>. Visual Studio 2005 users may use <a href="http://www.jetbrains.com/resharper/features/code_formatting.html#Namespace_Import_Directives_Optimization_full">ReSharper</a> for this.</p> <p>&nbsp;</p> <p>P.S. interesting, does&nbsp;this optimization&nbsp;gives you&nbsp;any benefits other than cleaner code?</p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><span style="font-weight:bold">kostya.ly</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZI__viTdl7g:KtXxF1AJIUA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZI__viTdl7g:KtXxF1AJIUA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZI__viTdl7g:KtXxF1AJIUA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZI__viTdl7g:KtXxF1AJIUA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZI__viTdl7g:KtXxF1AJIUA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZI__viTdl7g:KtXxF1AJIUA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZI__viTdl7g:KtXxF1AJIUA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZI__viTdl7g:KtXxF1AJIUA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZI__viTdl7g:KtXxF1AJIUA:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/ZI__viTdl7g" height="1" width="1"/> http://dotnettipoftheday.org/tips/get-rid-of-unused-usings.aspx Mon, 12 May 2008 20:05:08 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=get-rid-of-unused-usings Capitalization of ID and OK abbreviations used in identifiers <p>I was wondering how to&nbsp;capitalize&nbsp;properties which have either ID or OK abbreviation in its name. For example, is it&nbsp;TipID or TipId?&nbsp;I have found the answer in <a href="http://msdn.microsoft.com/en-us/library/ms229042.aspx">Design Guidelines for Developing Class Libraries</a>:</p> <p><em>In Pascal-cased identifiers (all identifiers except parameter names)&nbsp;they should appear as <span class="code">Id</span>, and <span class="code">Ok</span>. If used as the first word in a camel-cased identifier, they should appear as <span class="code">id</span> and <span class="code">ok</span>, respectively.</em></p> <p>&nbsp;</p> <p>P.S. And of course .NET Framework doesn't fulfil this rule :) For example, <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid.aspx">Control.ClientID</a> property.</p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><span style="font-weight:bold">kostya.ly</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bOobPPMmppE:yYP-Jqiqyi4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bOobPPMmppE:yYP-Jqiqyi4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bOobPPMmppE:yYP-Jqiqyi4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bOobPPMmppE:yYP-Jqiqyi4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bOobPPMmppE:yYP-Jqiqyi4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bOobPPMmppE:yYP-Jqiqyi4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bOobPPMmppE:yYP-Jqiqyi4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bOobPPMmppE:yYP-Jqiqyi4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bOobPPMmppE:yYP-Jqiqyi4:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/bOobPPMmppE" height="1" width="1"/> http://dotnettipoftheday.org/tips/capitalization-of-id-and-ok-abbreviations-used-in-identifiers.aspx Wed, 07 May 2008 01:59:56 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=capitalization-of-id-and-ok-abbreviations-used-in-identifiers How to loop through all rows of the DataTable? <div style="font-family:Courier New; font-size:10pt; color:#000000"> <p style="margin: 0px;"><span style="color: #0000FF">foreach</span> (DataRow row <span style="color: #0000FF">in</span> dTable.Rows)</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">yourvariable = row[<span style="color: #a31515">"ColumnName"</span>].ToString();</p> <p style="margin: 0px;">}</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;"><span style="color: #008200">//OR </span></p> <p style="margin: 0px;"><span style="color: #0000FF">for</span> (<span style="color: #0000FF">int</span> j = 0; j&lt; dTable.Rows.Count; j++)</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">yourvariable = dTable.Rows[j][<span style="color: #a31515">"ColumnName"</span>].ToString()l</p> <p style="margin: 0px;">}</p> <p style="margin: 0px;">&nbsp;</p> </div><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.dotnetfunda.com/profile/Raja.aspx" style="font-weight:bold">Raja</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JSpSDXRBTUc:WKmY0qCWQE8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JSpSDXRBTUc:WKmY0qCWQE8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JSpSDXRBTUc:WKmY0qCWQE8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JSpSDXRBTUc:WKmY0qCWQE8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JSpSDXRBTUc:WKmY0qCWQE8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JSpSDXRBTUc:WKmY0qCWQE8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JSpSDXRBTUc:WKmY0qCWQE8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JSpSDXRBTUc:WKmY0qCWQE8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JSpSDXRBTUc:WKmY0qCWQE8:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/JSpSDXRBTUc" height="1" width="1"/> http://dotnettipoftheday.org/tips/b2da9bd7-6629-4397-bd12-fd49072e88b4.aspx Wed, 30 Apr 2008 19:35:54 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=b2da9bd7-6629-4397-bd12-fd49072e88b4 To avoid line by line debug using F11 <p>Use DebuggerStepThroughAttribute</p> <p>&nbsp;[System.Diagnostics.DebuggerStepThrough()]</p> <p>public void sample()</p> <p>{</p> <p>// ....</p> <p>}</p> <p>&nbsp;</p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><span style="font-weight:bold">dhanaid</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bUy1CZxPVSQ:7ypfC7RTH1A:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bUy1CZxPVSQ:7ypfC7RTH1A:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bUy1CZxPVSQ:7ypfC7RTH1A:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bUy1CZxPVSQ:7ypfC7RTH1A:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bUy1CZxPVSQ:7ypfC7RTH1A:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bUy1CZxPVSQ:7ypfC7RTH1A:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bUy1CZxPVSQ:7ypfC7RTH1A:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bUy1CZxPVSQ:7ypfC7RTH1A:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bUy1CZxPVSQ:7ypfC7RTH1A:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/bUy1CZxPVSQ" height="1" width="1"/> http://dotnettipoftheday.org/tips/b086b5ee-4547-4ed6-abce-5f4ad8ecf47a.aspx Tue, 29 Apr 2008 13:58:47 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=b086b5ee-4547-4ed6-abce-5f4ad8ecf47a Bind a TreeView to a DataSet or an ObjectDataSource with one line of code <p>This post has a class that allows you to&nbsp;bind your TreeView to a dataSet very easily.&nbsp;</p> <p><a href="http://www.varjabedian.net/archive/2008/04/22/binding-asp.net-treeview-to-a-dataset-or-an-objectdatasource.aspx">http://www.varjabedian.net/archive/2008/04/22/binding-asp.net-treeview-to-a-dataset-or-an-objectdatasource.aspx</a></p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://varjabedian.net" style="font-weight:bold">Ralph Varjabedian</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=XPJ0EIfVe30:JFq0S3pPGNQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=XPJ0EIfVe30:JFq0S3pPGNQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=XPJ0EIfVe30:JFq0S3pPGNQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=XPJ0EIfVe30:JFq0S3pPGNQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=XPJ0EIfVe30:JFq0S3pPGNQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=XPJ0EIfVe30:JFq0S3pPGNQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=XPJ0EIfVe30:JFq0S3pPGNQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=XPJ0EIfVe30:JFq0S3pPGNQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=XPJ0EIfVe30:JFq0S3pPGNQ:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/XPJ0EIfVe30" height="1" width="1"/> http://dotnettipoftheday.org/tips/b5a838eb-09f9-4e5a-a911-d5b7cfbce413.aspx Wed, 23 Apr 2008 15:19:16 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=b5a838eb-09f9-4e5a-a911-d5b7cfbce413 Usuful VS Shortcuts <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">F7</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Jump to Code Behind</span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"><span style="font-family: Times New Roman;"> </span></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">Ctrl+F6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Navigate between various opened panes</span></em><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">Ctrl+Shift+V</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;Cycle through the clipboard ring</span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">CTRL+K+K&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create or delete Bookmark</span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">Ctrl+K+D</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Auto-format whole page</span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">Ctrl+K+F</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Auto-format selection</span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">Ctrl+U</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Convert to lower case</span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">Ctrl+Shift+U</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;Convert to upper case</span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">Ctrl+M+M&nbsp;</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fold/Unfold the current code block</span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">Ctrl+M+L</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Unfold all</span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></span></p> <p class="null" style="background: #fff8d9; margin: 0in 0in 0pt;"><span style="font-size: small;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">Block Selection</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;" lang="EN">&nbsp; Press and hold Alt and then select the area you want with your mouse.</span></span><span style="color: #080808; mso-ansi-language: EN;" lang="EN"></span></p><p style="font-style:italic; margin-top:20px;">submitted by <img src="http://dotnettipoftheday.org/WebResource.axd?d=7hUA8mJHzEvc1xYhl12jQc3FW-tarUzjw3EtIkxuLJnCfjryDyAts6YLEvrqJwaoBTuByEwza_f1tXTeXKhCgBbQL1bg1buL_1WeJo1lok0k343hcIAkoZLgpr9xRTu00&t=633458066039692085" style="vertical-align:middle" /><span style="font-weight:bold">eswarp</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nbr_dz-Ses0:LyTlkcsBiiI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=nbr_dz-Ses0:LyTlkcsBiiI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nbr_dz-Ses0:LyTlkcsBiiI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=nbr_dz-Ses0:LyTlkcsBiiI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nbr_dz-Ses0:LyTlkcsBiiI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=nbr_dz-Ses0:LyTlkcsBiiI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nbr_dz-Ses0:LyTlkcsBiiI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=nbr_dz-Ses0:LyTlkcsBiiI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=nbr_dz-Ses0:LyTlkcsBiiI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/nbr_dz-Ses0" height="1" width="1"/> http://dotnettipoftheday.org/tips/a0fe6f3b-96cd-4a7e-ba20-1c2df728c7e9.aspx Thu, 17 Apr 2008 20:23:07 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=a0fe6f3b-96cd-4a7e-ba20-1c2df728c7e9 Useful VS Shortcuts <p class="null" style="MARGIN: 0in 0in 0pt"><span style="color: #080808; mso-ansi-language: EN;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">F7</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Jump to Code Behind</span><font style="color: #080808; mso-ansi-language: EN;" color="#080808"><font size="3"><font face="Times New Roman"> <p class="null" style="MARGIN: 0in 0in 0pt"> <p> <p class="null" style="MARGIN: 0in 0in 0pt"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">Ctrl+F6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Navigate between various opened panes</span></em></p> <p class="null" style="MARGIN: 0in 0in 0pt"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">Ctrl+Shift+V</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">&nbsp;&nbsp;&nbsp;&nbsp;Cycle through the clipboard ring</span></p> <p class="null" style="MARGIN: 0in 0in 0pt"><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">CTRL+K+K&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create or delete Bookmark</span></p> <p class="null" style="MARGIN: 0in 0in 0pt"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">Ctrl+K+D</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Auto-format whole page</span></p> <p class="null" style="MARGIN: 0in 0in 0pt"><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;"><em>Ctrl+K+F</em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Auto-format selection</span></p> <p class="null" style="MARGIN: 0in 0in 0pt"><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;"><em>Ctrl+U</em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Convert to lower case</span></p> <p class="null" style="MARGIN: 0in 0in 0pt"><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;"><em>Ctrl+Shift+U</em>&nbsp;&nbsp;&nbsp;&nbsp;Convert to upper case</span></p> <p class="null" style="MARGIN: 0in 0in 0pt"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">Ctrl+M+M&nbsp;</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fold/Unfold the current code block</span></p> <p class="null" style="MARGIN: 0in 0in 0pt"><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;"><em>Ctrl+M+L</em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Unfold all</span></p> <p class="null" style="MARGIN: 0in 0in 0pt"><em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">Block Selection</span></em><span style="color: #080808; font-family: Arial; mso-ansi-language: EN;">&nbsp; Press and hold Alt and then select the area you want with your mouse.</span></p> <p>&nbsp;</p> </p> </p> </font></font></font></span><font style="color: #080808; mso-ansi-language: EN;" color="#080808"><font size="3"> <p class="null" style="MARGIN: 0in 0in 0pt">&nbsp;</p> </font></font></span><font style="color: #080808; mso-ansi-language: EN;" color="#080808"> <p class="null" style="MARGIN: 0in 0in 0pt">&nbsp;</p> </font></span></p> <p class="null" style="MARGIN: 0in 0in 0pt">&nbsp;</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Eswar</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=7Ic-h-aedjs:_-MBOh1qRUQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=7Ic-h-aedjs:_-MBOh1qRUQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=7Ic-h-aedjs:_-MBOh1qRUQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=7Ic-h-aedjs:_-MBOh1qRUQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=7Ic-h-aedjs:_-MBOh1qRUQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=7Ic-h-aedjs:_-MBOh1qRUQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=7Ic-h-aedjs:_-MBOh1qRUQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=7Ic-h-aedjs:_-MBOh1qRUQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=7Ic-h-aedjs:_-MBOh1qRUQ:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/7Ic-h-aedjs" height="1" width="1"/> http://dotnettipoftheday.org/tips/89b6e2ba-60ba-4b0b-9323-60270a59e7e2.aspx Thu, 17 Apr 2008 20:20:45 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=89b6e2ba-60ba-4b0b-9323-60270a59e7e2 Summary Tag in visual studio 2008 IDE <p>want to XML comment ur code ??</p> <p>just type /// (three slashes) on top of any class or method and the vs 2008 ide will automaticaly generate summary tag which will also give you out of the box functionality of intellisense when you use the particualar method with summary tag here is an example</p> <p><a title="screenshot from msdn" href="http://msdn.microsoft.com/vstudio/tour/vs2005_guided_tour/VS2005pro/Library/XMLComments.2.jpg" target="_blank">http://msdn.microsoft.com/vstudio/tour/vs2005_guided_tour/VS2005pro/Library/XMLComments.2.jpg</a></p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">l33tc0der</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HUg-VWKEEGY:7A_Tyqa3hMQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=HUg-VWKEEGY:7A_Tyqa3hMQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HUg-VWKEEGY:7A_Tyqa3hMQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=HUg-VWKEEGY:7A_Tyqa3hMQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HUg-VWKEEGY:7A_Tyqa3hMQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=HUg-VWKEEGY:7A_Tyqa3hMQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HUg-VWKEEGY:7A_Tyqa3hMQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HUg-VWKEEGY:7A_Tyqa3hMQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=HUg-VWKEEGY:7A_Tyqa3hMQ:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/HUg-VWKEEGY" height="1" width="1"/> http://dotnettipoftheday.org/tips/3C2582C4-551B-487A-90CE-643CB6C0306C.aspx Sun, 06 Apr 2008 01:00:59 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=3C2582C4-551B-487A-90CE-643CB6C0306C Can you store multiple data types in System.Array? <p>If you search the answer for this questions, you will find most websites just copy the answer "No", but actualy the correct answer should be Yes, because the code below proves it: C# System.Object[] test_array = new System.Object[6]; test_array[0]="123go!"; test_array[1]=2007.7; test_array[2]=true;</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://kailashdhondiyal.brainuse.com" style="font-weight:bold">Kailash Dhondiyal</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=r72NynzKF-0:gms9eFPrhbY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=r72NynzKF-0:gms9eFPrhbY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=r72NynzKF-0:gms9eFPrhbY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=r72NynzKF-0:gms9eFPrhbY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=r72NynzKF-0:gms9eFPrhbY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=r72NynzKF-0:gms9eFPrhbY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=r72NynzKF-0:gms9eFPrhbY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=r72NynzKF-0:gms9eFPrhbY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=r72NynzKF-0:gms9eFPrhbY:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/r72NynzKF-0" height="1" width="1"/> http://dotnettipoftheday.org/tips/654E4F30-17FF-4357-B544-D3502FF3A60C.aspx Sat, 05 Apr 2008 21:03:45 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=654E4F30-17FF-4357-B544-D3502FF3A60C Parse vs TryParse in conversion from string <p>Consider using TryParse and TryParseExact when converting from string to int, long, DateTime, etc. TryParse functions return true if conversion was successful and resulted value returned in out parameter. They do not throw an exception, which is a lot faster than Parse functions.</p> <div style="font-family:Courier New; font-size:10pt; color:#000000"> <p style="margin: 0px;"><span style="color: #0000FF">string</span> ageStr = <span style="color: #a31515">"35"</span>;</p> <p style="margin: 0px;"><span style="color: #0000FF">string</span> invalidAgeStr = <span style="color: #a31515">"TestAge 35"</span>;</p> <p style="margin: 0px;"><span style="color: #0000FF">int</span> age = 0;</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;"><span style="color: #0000FF">if</span> (<span style="color: #0000FF">int</span>.TryParse(ageStr, <span style="color: #0000FF">out</span> age))</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; MessageBox.Show(<span style="color: #a31515">"Age: "</span> + age);</p> <p style="margin: 0px;">}</p> <p style="margin: 0px;"><span style="color: #0000FF">if</span> (!<span style="color: #0000FF">int</span>.TryParse(invalidAgeStr, <span style="color: #0000FF">out</span> age))</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; MessageBox.Show(<span style="color: #a31515">"Invalid Age: "</span> + invalidAgeStr);</p> <p style="margin: 0px;">}</p> </div> &nbsp;<p style="font-style:italic; margin-top:20px;">submitted by <a href="http://software-development-toolbox.blogspot.com/" style="font-weight:bold">Vlad</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ep25AAcfrPM:gnDOCIouRWA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ep25AAcfrPM:gnDOCIouRWA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ep25AAcfrPM:gnDOCIouRWA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ep25AAcfrPM:gnDOCIouRWA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ep25AAcfrPM:gnDOCIouRWA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ep25AAcfrPM:gnDOCIouRWA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ep25AAcfrPM:gnDOCIouRWA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ep25AAcfrPM:gnDOCIouRWA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ep25AAcfrPM:gnDOCIouRWA:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/ep25AAcfrPM" height="1" width="1"/> http://dotnettipoftheday.org/tips/36F0558F-E7C1-4D13-A107-26268B24F700.aspx Thu, 03 Apr 2008 06:51:25 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=36F0558F-E7C1-4D13-A107-26268B24F700 Opening file in Windows Explorer - Faster <p>Using this tip to add the Windows Explorer to the tools list <a href="http://dotnettipoftheday.org/tips/explorer-in-tools-menu.aspx">http://dotnettipoftheday.org/tips/explorer-in-tools-menu.aspx</a>. You can assign a keyboard shortcut to it.</p> <p>Open the tools menu to identify which external command the Windows Explorer is set as, then select Tools -&gt; Customize and choose Keyboard. Enter "External Command" in the search box. Select the command number based on what was displayed in the tools menu and assign a keyboard shortcut.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.madcookie.net" style="font-weight:bold">MADCookie</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=EhkwAsYz1z0:QjNG45GYQNs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=EhkwAsYz1z0:QjNG45GYQNs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=EhkwAsYz1z0:QjNG45GYQNs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=EhkwAsYz1z0:QjNG45GYQNs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=EhkwAsYz1z0:QjNG45GYQNs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=EhkwAsYz1z0:QjNG45GYQNs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=EhkwAsYz1z0:QjNG45GYQNs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=EhkwAsYz1z0:QjNG45GYQNs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=EhkwAsYz1z0:QjNG45GYQNs:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/EhkwAsYz1z0" height="1" width="1"/> http://dotnettipoftheday.org/tips/0D8AD841-551B-47D7-ADC9-4FC31E48487D.aspx Mon, 24 Mar 2008 18:57:32 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=0D8AD841-551B-47D7-ADC9-4FC31E48487D Use &quot;it's&quot; and &quot;its&quot; Correctly "it's" is the contraction of "it is" "its" is possessive If you can re-word your "its" as "it is" then you're not using it correctly. <p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Rich Wilson</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=YHbPpLqz2B8:iEKM7W9byfI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=YHbPpLqz2B8:iEKM7W9byfI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=YHbPpLqz2B8:iEKM7W9byfI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=YHbPpLqz2B8:iEKM7W9byfI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=YHbPpLqz2B8:iEKM7W9byfI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=YHbPpLqz2B8:iEKM7W9byfI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=YHbPpLqz2B8:iEKM7W9byfI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=YHbPpLqz2B8:iEKM7W9byfI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=YHbPpLqz2B8:iEKM7W9byfI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/YHbPpLqz2B8" height="1" width="1"/> http://dotnettipoftheday.org/tips/2707B35E-FE43-48E7-8F0D-EDF556425E3F.aspx Mon, 24 Mar 2008 18:52:11 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=2707B35E-FE43-48E7-8F0D-EDF556425E3F Get UserId from User Name in ASP.NET <div style="font-family:Courier New; font-size:10pt; color:#000000"> <p style="margin: 0px;">MembershipUser myUser = Membership.GetUser();</p> <p style="margin: 0px;"><span style="color: #0000ff;">string</span> userID = myUser.ProviderUserKey.ToString()</p> </div> <p>or</p> <div style="font-family:Courier New; font-size:10pt; color:#000000"> <p style="margin: 0px;">MembershipUser myUser = Membership.GetUser(My.User.Name);</p> <p style="margin: 0px;"><span style="color: #0000ff;">string</span> userID = myUser.ProviderUserKey.ToString()</p> </div> <p>&nbsp;&nbsp;</p> <p><span style="text-decoration: underline;">Links</span></p> <ul> <li><a href=" http://msdn2.microsoft.com/en-us/library/system.web.security.membership.getuser.aspx">Membership.GetUser Method</a><br />Gets the information for a membership user from the data source.</li> </ul><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://geeks.ms/blogs/fernandezja" style="font-weight:bold">Jose A. Fernandez</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hpnPgz4JtRE:WWi_n0xHxR4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=hpnPgz4JtRE:WWi_n0xHxR4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hpnPgz4JtRE:WWi_n0xHxR4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=hpnPgz4JtRE:WWi_n0xHxR4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hpnPgz4JtRE:WWi_n0xHxR4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=hpnPgz4JtRE:WWi_n0xHxR4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hpnPgz4JtRE:WWi_n0xHxR4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=hpnPgz4JtRE:WWi_n0xHxR4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=hpnPgz4JtRE:WWi_n0xHxR4:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/hpnPgz4JtRE" height="1" width="1"/> http://dotnettipoftheday.org/tips/EE173589-310F-4ACC-A090-BA6A2F747F9B.aspx Mon, 17 Mar 2008 09:07:13 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=EE173589-310F-4ACC-A090-BA6A2F747F9B Reading Eventlog of a Remote Machine <p>Reading Eventlog of a Remote Machine</p> <ol> <li>Include System.Diagnostics</li> <li>Getting the eventlogs of a remote machine say MachineName<br /> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;">EventLog[] eLogs = EventLog.GetEventLogs(MachineName); <span style="color: #008200;">//Can also use IPAddress of the machine as EventLog.GetEventLogs(IPAddress)</span></p> </div> The name of the ith eventlog can be obtained from the eLogs[i].LogDisplayName property of the eventlog object.</li> <li>Suppose we want to get the object for the eventlog named MyEventLog in machine MachineName. We can get that as:<br /> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;">EventLog elog = <span style="color: #0000ff;">new</span> EventLog(MyEventLog , MachineName);</p> </div> </li> <li>To access the different entries in the eventlog we can use the array eLog.Entries<br />For ith entry, the different properties we can get are:<br /> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;">elog.Entries[i].EntryType</p> <p style="margin: 0px;">elog.Entries[i].TimeGenerated</p> <p style="margin: 0px;">elog.Entries[i].Source</p> <p style="margin: 0px;">elog.Entries[i].Category</p> <p style="margin: 0px;">elog.Entries[i].InstanceId</p> <p style="margin: 0px;">elog.Entries[i].UserName</p> <p style="margin: 0px;">elog.Entries[i].Message</p> <p style="margin: 0px;">elog.Entries[i].MachineName</p> </div> </li> </ol><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Saurav Kumar Jaiswal</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=jnwVgbpgQEA:HDNYQ1qWOZs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=jnwVgbpgQEA:HDNYQ1qWOZs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=jnwVgbpgQEA:HDNYQ1qWOZs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=jnwVgbpgQEA:HDNYQ1qWOZs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=jnwVgbpgQEA:HDNYQ1qWOZs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=jnwVgbpgQEA:HDNYQ1qWOZs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=jnwVgbpgQEA:HDNYQ1qWOZs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=jnwVgbpgQEA:HDNYQ1qWOZs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=jnwVgbpgQEA:HDNYQ1qWOZs:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/jnwVgbpgQEA" height="1" width="1"/> http://dotnettipoftheday.org/tips/EC8E14E4-4C95-4CA0-A8E6-C06882F2237D.aspx Tue, 04 Mar 2008 14:41:49 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=EC8E14E4-4C95-4CA0-A8E6-C06882F2237D Add Windows Explorer to your Visual Studio tools menu <p>I often need to open Windows Explorer and browse to the current file, folder, or project that I am working on in Visual Studio.&nbsp;This tip allows you to achieve this by clicking "Windows Explorer" in the Tools menu, and is one of the most simple-yet-useful tips I know of.</p> <p>To set it up, click "Tools", then "External Tools...", then click "Add".&nbsp; Now enter the following data:<br />Title: Windows Explorer<br />Command: explorer.exe<br />Arguments: /select,"$(ItemPath)"</p> <p>Leave "Initial directoy" blank, and click "OK".&nbsp; Now when you click "Tools", "Windows Explorer", Windows Explorer will open with the current file you are editing selected.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.picwa.com" style="font-weight:bold">Daniel Flower</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=SkCQVB4jMaA:HFJHltg6GaA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=SkCQVB4jMaA:HFJHltg6GaA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=SkCQVB4jMaA:HFJHltg6GaA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=SkCQVB4jMaA:HFJHltg6GaA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=SkCQVB4jMaA:HFJHltg6GaA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=SkCQVB4jMaA:HFJHltg6GaA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=SkCQVB4jMaA:HFJHltg6GaA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=SkCQVB4jMaA:HFJHltg6GaA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=SkCQVB4jMaA:HFJHltg6GaA:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/SkCQVB4jMaA" height="1" width="1"/> http://dotnettipoftheday.org/tips/CC6C910F-1A7B-4682-B819-6905F9AD5F17.aspx Sun, 24 Feb 2008 05:57:40 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=CC6C910F-1A7B-4682-B819-6905F9AD5F17 Toggle intelisense transperancy on the fly <p>When typing in VS2008 and intellisense blocks the view of the lines of code underneath. You can hold down the <code style="color:teal">Ctrl</code> key to toggle the opacity of the intelisense box so that you can see the code under it.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.nansen.se" style="font-weight:bold">Kalle Hoppe</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=DTRit6-DPE8:vgtmsko5XCI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=DTRit6-DPE8:vgtmsko5XCI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=DTRit6-DPE8:vgtmsko5XCI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=DTRit6-DPE8:vgtmsko5XCI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=DTRit6-DPE8:vgtmsko5XCI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=DTRit6-DPE8:vgtmsko5XCI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=DTRit6-DPE8:vgtmsko5XCI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=DTRit6-DPE8:vgtmsko5XCI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=DTRit6-DPE8:vgtmsko5XCI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/DTRit6-DPE8" height="1" width="1"/> http://dotnettipoftheday.org/tips/1B1C8319-4B17-45D9-AE7B-365563CABD40.aspx Mon, 18 Feb 2008 12:32:55 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=1B1C8319-4B17-45D9-AE7B-365563CABD40 WPF Textbox memory leak <p>While running around in the WPF forums, I found this very interesting post (<a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2823829&amp;SiteID=1">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2823829&amp;SiteID=1</a>)&hellip; It seems that the WPF TextBox can be dangerous :) - if you do not use it carefully :)</p> <p>Basically the TextBox by default stores all text changes in an Undo Stack&hellip; This implies that every time that you change the Text of the TextBox more memory is consumed by the TextBox.</p> <p>In order to fix this you have to set the UndoLimit property to 0. This would disable the Undo feature for the TextBox and thus NO MORE MEMORY CONSUMPTION &hellip;</p> <p>Have a nice day</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://marlongrech.wordpress.com" style="font-weight:bold">Marlon Grech</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bpS7Klh8pTQ:KbgkZCldz_8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bpS7Klh8pTQ:KbgkZCldz_8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bpS7Klh8pTQ:KbgkZCldz_8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bpS7Klh8pTQ:KbgkZCldz_8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bpS7Klh8pTQ:KbgkZCldz_8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bpS7Klh8pTQ:KbgkZCldz_8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bpS7Klh8pTQ:KbgkZCldz_8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=bpS7Klh8pTQ:KbgkZCldz_8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=bpS7Klh8pTQ:KbgkZCldz_8:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/bpS7Klh8pTQ" height="1" width="1"/> http://dotnettipoftheday.org/tips/006BBAA9-AAAC-4CB3-9F2B-09A5D0475E59.aspx Sat, 16 Feb 2008 12:27:39 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=006BBAA9-AAAC-4CB3-9F2B-09A5D0475E59 Format your code <p>You can format your code by selecting the code you want to format and pressing <code style="color:teal">ctl + K +F</code>. This shortcut can also be applied to html.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="bshouman.blogspot.com" style="font-weight:bold">Bilal Shouman</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=86bsHmp1wOc:XzWvQ-_H_R4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=86bsHmp1wOc:XzWvQ-_H_R4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=86bsHmp1wOc:XzWvQ-_H_R4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=86bsHmp1wOc:XzWvQ-_H_R4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=86bsHmp1wOc:XzWvQ-_H_R4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=86bsHmp1wOc:XzWvQ-_H_R4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=86bsHmp1wOc:XzWvQ-_H_R4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=86bsHmp1wOc:XzWvQ-_H_R4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=86bsHmp1wOc:XzWvQ-_H_R4:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/86bsHmp1wOc" height="1" width="1"/> http://dotnettipoftheday.org/tips/E74C89DB-48C6-4477-A0DE-61FBB0AF7768.aspx Tue, 12 Feb 2008 00:51:30 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=E74C89DB-48C6-4477-A0DE-61FBB0AF7768 Adding required field validator to DropDownList <p>You can set a required field validator to a drop down list as follows</p> <p>&lt;asp:DropDownList ID="ddlItems" runat="server"&gt;<br />&nbsp;&nbsp;&nbsp; &lt;asp:ListItem Text="&lt;--Select Item--&gt;" Value=""&gt;&lt;/asp:ListItem&gt;<br />&nbsp;&nbsp;&nbsp; &lt;asp:ListItem Text="Item 1" Value="1"&gt;&lt;/asp:ListItem&gt;<br />&nbsp;&nbsp;&nbsp; &lt;asp:ListItem Text="Item 2" Value="2"&gt;&lt;/asp:ListItem&gt;<br />&nbsp;&nbsp;&nbsp; &lt;asp:ListItem Text="Item 3" Value="3"&gt;&lt;/asp:ListItem&gt;<br />&lt;/asp:DropDownList&gt;</p> <p>&lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="ddlItems" runat="server" ErrorMessage="Please select an item" Text="Pelase select an Item"&gt;&lt;/asp:RequiredFieldValidator&gt;</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="bshouman.blogspot.com" style="font-weight:bold">Bilal Shouman</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kVIQdUEhkec:R-OAxI2TM2c:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=kVIQdUEhkec:R-OAxI2TM2c:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kVIQdUEhkec:R-OAxI2TM2c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=kVIQdUEhkec:R-OAxI2TM2c:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kVIQdUEhkec:R-OAxI2TM2c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=kVIQdUEhkec:R-OAxI2TM2c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kVIQdUEhkec:R-OAxI2TM2c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=kVIQdUEhkec:R-OAxI2TM2c:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=kVIQdUEhkec:R-OAxI2TM2c:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/kVIQdUEhkec" height="1" width="1"/> http://dotnettipoftheday.org/tips/D2D20128-821A-41D8-9DD3-4F26CFFB7AB8.aspx Tue, 12 Feb 2008 00:32:17 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=D2D20128-821A-41D8-9DD3-4F26CFFB7AB8 Show/Hide ASP.NET Non-visual controls in the designer <p>Sometimes it is useful to show/hide ASP.NET Non-visual controls in the designer. For this:</p> <ol> <li>Swith to Design view</li> <li>From the View menu, click Visual Aids and select/unselect ASP.NET Non-visual Control option or just press <code style="color:teal">CTRL+SHIFT+N</code>.</li> </ol> <p>Enjoy! :)</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.godevs.com" style="font-weight:bold">Sergey P.</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HXcj0cW7Hfs:BS8JmJvtwJk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=HXcj0cW7Hfs:BS8JmJvtwJk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HXcj0cW7Hfs:BS8JmJvtwJk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=HXcj0cW7Hfs:BS8JmJvtwJk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HXcj0cW7Hfs:BS8JmJvtwJk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=HXcj0cW7Hfs:BS8JmJvtwJk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HXcj0cW7Hfs:BS8JmJvtwJk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=HXcj0cW7Hfs:BS8JmJvtwJk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=HXcj0cW7Hfs:BS8JmJvtwJk:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/HXcj0cW7Hfs" height="1" width="1"/> http://dotnettipoftheday.org/tips/B0681AC4-6F65-44C3-B793-ABFFDBA0967D.aspx Mon, 11 Feb 2008 13:19:51 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=B0681AC4-6F65-44C3-B793-ABFFDBA0967D Chaining the C# ?? Operator <p>In C# you can shortcut this special null comparison case with the new ??:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">string</span> result = value1 ?? value2;</p> </div> <p>which is a little easier to write. This is probably not news to you, but what's really useful is that you can chain these operators together so you can do a whole bunch of null comparisons in a single stroke. For example, I frequently look for a few different querystring variables in a page:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">string</span> partner = Request.QueryString[<span style="color: #a31515">"GoogleId"</span>] ??</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; Request.QueryString[<span style="color: #a31515">"PartnerId"</span>] ??</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; Request.QueryString[<span style="color: #a31515">"UserKey"</span>] ??</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">string</span>.Empty;</p> </div> <p>which still yields a valid result for the first non-null querystring or if nothing is found returning "".</p> <p>More found here: <a href="http://www.west-wind.com/weblog/posts/236298.aspx">http://www.west-wind.com/weblog/posts/236298.aspx</a>&nbsp;</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.west-wind.com/weblog/posts/236298.aspx" style="font-weight:bold">Jacob Cook</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vO6vrL8J4bU:SfZjhniBSTU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=vO6vrL8J4bU:SfZjhniBSTU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vO6vrL8J4bU:SfZjhniBSTU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=vO6vrL8J4bU:SfZjhniBSTU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vO6vrL8J4bU:SfZjhniBSTU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=vO6vrL8J4bU:SfZjhniBSTU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vO6vrL8J4bU:SfZjhniBSTU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vO6vrL8J4bU:SfZjhniBSTU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=vO6vrL8J4bU:SfZjhniBSTU:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/vO6vrL8J4bU" height="1" width="1"/> http://dotnettipoftheday.org/tips/FFC1B3B2-2F81-4CA3-A9E2-9E91C6465448.aspx Tue, 29 Jan 2008 18:33:18 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=FFC1B3B2-2F81-4CA3-A9E2-9E91C6465448 How to enable Text Editor Guide Lines in Visual Studio <p>A not well known feature of Visual Studio (2002/3/5/8) is the ability to add a Guide Line to the text editor, which would show a visible line indicating a specific column. This feature of Visual Studio lets you display a vertical line at the column of your choosing to help visually see when a line is getting too long. This helps you to define a maximum acceptable column, where code should have a line break to look clear and sharp on all monitor resolutions.</p> <p>Please beware that registry manipulation is needed, so DO IT AT YOUR OWN RISK!</p> <p>Open a command prompt and run the following command:</p> <p>REG ADD "HKCU\Software\Microsoft\VisualStudio\[Version]\Text Editor" /v Guides /d "RGB([R],[G],[B]) [COL1], [COL2]"</p> <p>You should replace:</p> <ul> <li>[Version]- the Visual Studio Version (Please note: 2005 = 8.0 ; 2008 = 9.0)</li> <li>[R]&nbsp; = RGB Red value (0-255) of the line</li> <li>[G]&nbsp; = RGB Green value (0-255) of the line</li> <li>[B]&nbsp; = RGB Blue value (0-255) of the line</li> <li>[COL1] [COL2] = The column number where to show the line. You can have at most 13 lines.</li> </ul> <p>As an example, you can run the following command:</p> <p>REG ADD "HKCU\Software\Microsoft\VisualStudio\8.0\Text Editor" /v Guides /d "RGB(128,0,0) 80, 120</p> <p>Which would add two columns (column 80 and column 120).</p> <p>Voil&aacute;! Now you know when lines are to large...</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.arquitecturadesoftware.org/blogs/hugobatista" style="font-weight:bold">Hugo Batista</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=WPJX71Fp38o:OQnn-XzuyqQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=WPJX71Fp38o:OQnn-XzuyqQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=WPJX71Fp38o:OQnn-XzuyqQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=WPJX71Fp38o:OQnn-XzuyqQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=WPJX71Fp38o:OQnn-XzuyqQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=WPJX71Fp38o:OQnn-XzuyqQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=WPJX71Fp38o:OQnn-XzuyqQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=WPJX71Fp38o:OQnn-XzuyqQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=WPJX71Fp38o:OQnn-XzuyqQ:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/WPJX71Fp38o" height="1" width="1"/> http://dotnettipoftheday.org/tips/6B29ED91-DE6C-425F-9E28-95EED8153F0C.aspx Fri, 25 Jan 2008 19:29:05 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=6B29ED91-DE6C-425F-9E28-95EED8153F0C Disable Theming and StyleSheet theme for one specific page in Asp.Net <p>The theming features of asp.net works by just putting one line inside the Web.Config file, this to enable a theme and change the look of the complete website. But what to do when you want to disable everything for one specific page?</p> <p>There are 2 page directives, Theme and StyleSheetTheme that help setting the themes.</p> <p>&lt;%@ Page Language=&rdquo;C#&rdquo; Theme=&rdquo;OrangeTheme&rdquo; StyleSheetTheme=&rdquo;GreenTheme&rdquo; %&gt;</p> <p>&nbsp;</p> <p>But to disable them the documentation will only provide following answer.</p> <p>&lt;%@ Page Language=&rdquo;C#&rdquo; EnableTheming=&rdquo;false&rdquo; %&gt;</p> <p>&nbsp;</p> <p>But the EnableTheming will only effect the choosen theme and will not effect the StyleSheet theme!!!<br />So to disable both these features just use following code:</p> <p>&lt;%@ Page Language=&rdquo;C#&rdquo; Theme="" StyleSheetTheme="" %&gt;</p> <p>Took me a while to figure this one out :)</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://depblog.weblogs.us" style="font-weight:bold">Glenn Versweyveld</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=y6QYZyfL1yw:GuDjXPQFjCY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=y6QYZyfL1yw:GuDjXPQFjCY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=y6QYZyfL1yw:GuDjXPQFjCY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=y6QYZyfL1yw:GuDjXPQFjCY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=y6QYZyfL1yw:GuDjXPQFjCY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=y6QYZyfL1yw:GuDjXPQFjCY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=y6QYZyfL1yw:GuDjXPQFjCY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=y6QYZyfL1yw:GuDjXPQFjCY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=y6QYZyfL1yw:GuDjXPQFjCY:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/y6QYZyfL1yw" height="1" width="1"/> http://dotnettipoftheday.org/tips/3704C055-8F3A-4BD6-892B-8883296C62FA.aspx Fri, 25 Jan 2008 12:05:38 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=3704C055-8F3A-4BD6-892B-8883296C62FA Clear &quot;Recent Projects&quot; list from Start page in Visual Studio .NET <p>Here is a nice tips to clear the Recent project list or File list from "Start page" of Visual Studio.Net</p> <p>Go to Start -&gt; Run -&gt; RegEdit</p> <p>and navigate to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\\ProjectMRUList delete unnecessary list.</p> <p>Similarly for FileMRuList.</p> <p>Make sure not disturb other key from the registry.</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Kaushal</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=2pTIi3MBh1Y:nIGkbPA_wpc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=2pTIi3MBh1Y:nIGkbPA_wpc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=2pTIi3MBh1Y:nIGkbPA_wpc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=2pTIi3MBh1Y:nIGkbPA_wpc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=2pTIi3MBh1Y:nIGkbPA_wpc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=2pTIi3MBh1Y:nIGkbPA_wpc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=2pTIi3MBh1Y:nIGkbPA_wpc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=2pTIi3MBh1Y:nIGkbPA_wpc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=2pTIi3MBh1Y:nIGkbPA_wpc:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/2pTIi3MBh1Y" height="1" width="1"/> http://dotnettipoftheday.org/tips/E3F59036-93B2-40A0-A22E-805F6C227DD9.aspx Thu, 24 Jan 2008 14:35:08 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=E3F59036-93B2-40A0-A22E-805F6C227DD9 Automatic Properties <p>In the latest release of Orcas, one of the new features provided is "Automatic Properties" which allows developers to use a shorthand like the following:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">public</span> <span style="color: #0000FF">class</span> Person {</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">public</span> <span style="color: #0000FF">string</span> FirstName {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; get; set;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">public</span> <span style="color: #0000FF">string</span> LastName {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; get; set;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">public</span> <span style="color: #0000FF">int</span> Age {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; get; set;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">}</p> </div> <p>and the compiler knows to interpret this as</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">public</span> <span style="color: #0000FF">class</span> Person {</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">private</span> <span style="color: #0000FF">string</span> _firstName;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">private</span> <span style="color: #0000FF">string</span> _lastName;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">private</span> <span style="color: #0000FF">int</span> _age;</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">public</span> <span style="color: #0000FF">string</span> FirstName {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; get {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> _firstName;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _firstName = value;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">public</span> <span style="color: #0000FF">string</span> LastName {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; get {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> _lastName;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _lastName = value;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">public</span> <span style="color: #0000FF">int</span> Age {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; get {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> _age;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _age = value;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">}</p> </div><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Joe</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E4lqoJ7mZGE:Olf48qotckc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=E4lqoJ7mZGE:Olf48qotckc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E4lqoJ7mZGE:Olf48qotckc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=E4lqoJ7mZGE:Olf48qotckc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E4lqoJ7mZGE:Olf48qotckc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=E4lqoJ7mZGE:Olf48qotckc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E4lqoJ7mZGE:Olf48qotckc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=E4lqoJ7mZGE:Olf48qotckc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=E4lqoJ7mZGE:Olf48qotckc:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/E4lqoJ7mZGE" height="1" width="1"/> http://dotnettipoftheday.org/tips/26CE92F0-A02B-4FBE-ADFA-F4E9346833A9.aspx Thu, 17 Jan 2008 13:06:11 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=26CE92F0-A02B-4FBE-ADFA-F4E9346833A9 prop Code Snippet in VS 2005 <p>You can use the "prop" code snippet in VS 2005 to easily create properties inside a class. So, if you type prop inside a class in VS 2005, you will get something like:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">private</span> <span style="color: #0000FF">int</span> myVar;</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;"><span style="color: #0000FF">public</span> <span style="color: #0000FF">int</span> myProperty</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; get {<span style="color: #0000FF">return</span> myVar;}</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; set {myVar = Value;}</p> <p style="margin: 0px;">}</p> </div> <p>As you can see, it defaults to an int, but simply type string on line 1 and it will change both "int" fields to strings.&nbsp; Likewise, changing myVar will not only change it on the first line, but also in both locations within the get/set accessors (line 5 and 6).</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Joe</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=U8NblygPBWA:4l0VUxjOZI8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=U8NblygPBWA:4l0VUxjOZI8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=U8NblygPBWA:4l0VUxjOZI8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=U8NblygPBWA:4l0VUxjOZI8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=U8NblygPBWA:4l0VUxjOZI8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=U8NblygPBWA:4l0VUxjOZI8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=U8NblygPBWA:4l0VUxjOZI8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=U8NblygPBWA:4l0VUxjOZI8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=U8NblygPBWA:4l0VUxjOZI8:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/U8NblygPBWA" height="1" width="1"/> http://dotnettipoftheday.org/tips/15941056-2FDF-468B-AB4D-925BE705232A.aspx Thu, 17 Jan 2008 13:04:42 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=15941056-2FDF-468B-AB4D-925BE705232A Easily Creating Properties in VS 2005 (C#) <p>You can use the "prop" attribute to easily create properties in vs 2005 (C#).</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Joe</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=D-oObJH1F5k:r5848-10t_0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=D-oObJH1F5k:r5848-10t_0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=D-oObJH1F5k:r5848-10t_0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=D-oObJH1F5k:r5848-10t_0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=D-oObJH1F5k:r5848-10t_0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=D-oObJH1F5k:r5848-10t_0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=D-oObJH1F5k:r5848-10t_0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=D-oObJH1F5k:r5848-10t_0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=D-oObJH1F5k:r5848-10t_0:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/D-oObJH1F5k" height="1" width="1"/> http://dotnettipoftheday.org/tips/D3F9B01A-A171-4A2A-8497-43EA3D3BE423.aspx Tue, 15 Jan 2008 14:05:48 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=D3F9B01A-A171-4A2A-8497-43EA3D3BE423 Automatic Source Code Formatting <p>You can use <code style="color:teal">ctrl k + d</code> to automatically format your html of server code in VS 2005.</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Joe</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JAo0XBY1_0U:_-xTfK2Zb0c:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JAo0XBY1_0U:_-xTfK2Zb0c:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JAo0XBY1_0U:_-xTfK2Zb0c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JAo0XBY1_0U:_-xTfK2Zb0c:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JAo0XBY1_0U:_-xTfK2Zb0c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JAo0XBY1_0U:_-xTfK2Zb0c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JAo0XBY1_0U:_-xTfK2Zb0c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JAo0XBY1_0U:_-xTfK2Zb0c:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JAo0XBY1_0U:_-xTfK2Zb0c:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/JAo0XBY1_0U" height="1" width="1"/> http://dotnettipoftheday.org/tips/224C4FD4-B05B-4D4E-9D93-69D62B60F7EC.aspx Tue, 15 Jan 2008 13:47:21 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=224C4FD4-B05B-4D4E-9D93-69D62B60F7EC Launch DTS from Asp.net page <p><strong>Introduction</strong></p> <p>Data Trasformation Services (DTS) is a tool and set of programmable objects that lets you extract, trasform and consolidate data from various source into various destinations.</p> <p><strong>How to</strong></p> <p>Launch a DTS from Asp.net page is much useful, when you must import some data from disparate sources. First, add reference Microsoft.SqlServer.ManagedDTS to project. Place into the class the follow using:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">using</span> Microsoft.SqlServer.Dts.Runtime;</p> </div> <p>Now, into the page load event place this code:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">string</span> pkgLocation;</p> <p style="margin: 0px;">Package pkgImport;</p> <p style="margin: 0px;">Application appImport;</p> <p style="margin: 0px;">DTSExecResult pkgResults;</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">pkgLocation = @<span style="color: #a31515">"c:\temp\DtsTest.dtsx"</span>;</p> <p style="margin: 0px;">appImport = <span style="color: #0000FF">new</span> Application();</p> <p style="margin: 0px;">pkgImport = appImport.LoadPackage(pkgLocation, <span style="color: #0000FF">null</span>);</p> <p style="margin: 0px;">pkgResults = pkgImport.Execute();</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;"><span style="color: #0000FF">if</span> (pkgResults == DTSExecResult.Success)</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; TxtEsito.text = <span style="color: #a31515">"DTS Eseguito con successo."</span>;</p> <p style="margin: 0px;">}</p> </div> <p>Also, we can see the state of job using the follow state enumeration <a href="http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtsexecresult.aspx">http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtsexecresult.aspx</a></p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.emanuelebatolesi.com" style="font-weight:bold">Emanuele Bartolesi</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Z_e3hXIKEBw:BI6Oo5Yh9NM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Z_e3hXIKEBw:BI6Oo5Yh9NM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Z_e3hXIKEBw:BI6Oo5Yh9NM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Z_e3hXIKEBw:BI6Oo5Yh9NM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Z_e3hXIKEBw:BI6Oo5Yh9NM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Z_e3hXIKEBw:BI6Oo5Yh9NM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Z_e3hXIKEBw:BI6Oo5Yh9NM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Z_e3hXIKEBw:BI6Oo5Yh9NM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Z_e3hXIKEBw:BI6Oo5Yh9NM:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/Z_e3hXIKEBw" height="1" width="1"/> http://dotnettipoftheday.org/tips/9136A19F-BAC7-4943-B87B-6F26948E5270.aspx Tue, 15 Jan 2008 12:51:58 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=9136A19F-BAC7-4943-B87B-6F26948E5270 Operators ?: and ?? <p>Original code:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">string</span> f(<span style="color: #0000ff;">string</span> inputString)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">if</span> (inputString != <span style="color: #0000ff;">null</span>)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">return</span> inputString;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">else</span></p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">return</span> <span style="color: #a31515;">""</span>;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> </div> <p>operator ?</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">string</span> f(<span style="color: #0000ff;">string</span> inputString)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">return</span> (inputString != <span style="color: #0000ff;">null</span>) ? inputString : <span style="color: #a31515;">""</span>;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> </div> <p>operator ??</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">string</span> f(<span style="color: #0000ff;">string</span> inputString)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">return</span> (inputString) ?? <span style="color: #a31515;">""</span>;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> </div> <p><a href="http://msdn2.microsoft.com/en-us/library/ty67wk28.aspx">http://msdn2.microsoft.com/en-us/library/ty67wk28.aspx</a><br /><a href="http://msdn2.microsoft.com/en-us/library/ms173224.aspx">http://msdn2.microsoft.com/en-us/library/ms173224.aspx</a></p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">constructor</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=gVvNqXxlzIg:H9piY1mX-Pk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=gVvNqXxlzIg:H9piY1mX-Pk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=gVvNqXxlzIg:H9piY1mX-Pk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=gVvNqXxlzIg:H9piY1mX-Pk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=gVvNqXxlzIg:H9piY1mX-Pk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=gVvNqXxlzIg:H9piY1mX-Pk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=gVvNqXxlzIg:H9piY1mX-Pk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=gVvNqXxlzIg:H9piY1mX-Pk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=gVvNqXxlzIg:H9piY1mX-Pk:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/gVvNqXxlzIg" height="1" width="1"/> http://dotnettipoftheday.org/tips/BBC1D5E3-3E16-42EB-891E-F5A0F0A3046C.aspx Sun, 13 Jan 2008 18:00:24 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=BBC1D5E3-3E16-42EB-891E-F5A0F0A3046C Hide automatically generated column fields in GridView <p>Original article can be found at <a href="http://www.mycsharpcorner.com/Post.aspx?postID=49">http://www.mycsharpcorner.com/Post.aspx?postID=49</a></p> <p>When you bind a GridView to an ObjectSource in ASP.NET, sometimes, you don't want to display all of the columns returned from the ObjectSource DataTable, but if you use a GridView and let it autmatically generate the columns, it becomes not a striaght forward deal to hide the individual selected columns. Here is a way to do that:</p> <p>Simply catch the RowDataBound event on the GridView and if you know the index of the column to hide, just use it as follows:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">protected</span> <span style="color: #0000FF">void</span> GridView1_RowDataBound(<span style="color: #0000FF">object</span> sender, GridViewRowEventArgs e)</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">if</span> (e.Row.Cells.Count &gt;= 1)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; e.Row.Cells[1].Visible = <span style="color: #0000FF">false</span>;</p> <p style="margin: 0px;">}</p> </div> <p>Assuming you want to hide the second column in your automatically generated GridView.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.mycsharpcorner.com/" style="font-weight:bold">Jacob Cook</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tQJUArQKzsw:ylX51NZ6lEM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=tQJUArQKzsw:ylX51NZ6lEM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tQJUArQKzsw:ylX51NZ6lEM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=tQJUArQKzsw:ylX51NZ6lEM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tQJUArQKzsw:ylX51NZ6lEM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=tQJUArQKzsw:ylX51NZ6lEM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tQJUArQKzsw:ylX51NZ6lEM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tQJUArQKzsw:ylX51NZ6lEM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=tQJUArQKzsw:ylX51NZ6lEM:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/tQJUArQKzsw" height="1" width="1"/> http://dotnettipoftheday.org/tips/B092ACD9-EC74-434C-8517-966964281164.aspx Fri, 28 Dec 2007 06:55:17 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=B092ACD9-EC74-434C-8517-966964281164 Windows forms and ASP.NET FAQ You'll certainly find something usefull there. It's a great resource. http://www.syncfusion.com/FAQ/WindowsForms/Default.aspx http://www.syncfusion.com/faq/aspnet/default.aspx <p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.sotto.be/" style="font-weight:bold">sotto</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=VCUG4vECFlA:hYszqqLAVVw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=VCUG4vECFlA:hYszqqLAVVw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=VCUG4vECFlA:hYszqqLAVVw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=VCUG4vECFlA:hYszqqLAVVw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=VCUG4vECFlA:hYszqqLAVVw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=VCUG4vECFlA:hYszqqLAVVw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=VCUG4vECFlA:hYszqqLAVVw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=VCUG4vECFlA:hYszqqLAVVw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=VCUG4vECFlA:hYszqqLAVVw:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/VCUG4vECFlA" height="1" width="1"/> http://dotnettipoftheday.org/tips/965D24E9-EC39-4858-BA38-14002908DC35.aspx Fri, 28 Dec 2007 02:31:37 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=965D24E9-EC39-4858-BA38-14002908DC35 Cut a line into memory <p>By pressing <code style="color:teal">CTRL+L</code>, you can cut a line of code into memory. This is an easy way to move lines around your pages, or delete a set of lines quickly. Simple, yet useful!</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.thexboxlounge.co.za" style="font-weight:bold">Grant Merwitz</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mG10gbhTQBc:weOfAhykvAA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mG10gbhTQBc:weOfAhykvAA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mG10gbhTQBc:weOfAhykvAA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mG10gbhTQBc:weOfAhykvAA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mG10gbhTQBc:weOfAhykvAA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mG10gbhTQBc:weOfAhykvAA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mG10gbhTQBc:weOfAhykvAA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mG10gbhTQBc:weOfAhykvAA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mG10gbhTQBc:weOfAhykvAA:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/mG10gbhTQBc" height="1" width="1"/> http://dotnettipoftheday.org/tips/A21BF8AC-C63A-4040-92C5-B58DCC27A06A.aspx Mon, 24 Dec 2007 11:51:37 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=A21BF8AC-C63A-4040-92C5-B58DCC27A06A FYI To Man Manovich Hello Man. For some reason, the form in the Comments section of the tips is not having a good design with the following configuration: - IE 6 (specifically Version: 6.0.2900.2180) - XP Professional (with SP 2) I am not sure but it may be a possible CSS issue. Just wanted to let you know about it. Mustafa Basgun mbasgun@yahoo.com <p style="font-style:italic; margin-top:20px;">submitted by <a href=" " style="font-weight:bold">Mustafa Basgun</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=RyHu3ENHHOc:JM5B-CIvq8I:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=RyHu3ENHHOc:JM5B-CIvq8I:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=RyHu3ENHHOc:JM5B-CIvq8I:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=RyHu3ENHHOc:JM5B-CIvq8I:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=RyHu3ENHHOc:JM5B-CIvq8I:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=RyHu3ENHHOc:JM5B-CIvq8I:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=RyHu3ENHHOc:JM5B-CIvq8I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=RyHu3ENHHOc:JM5B-CIvq8I:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=RyHu3ENHHOc:JM5B-CIvq8I:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/RyHu3ENHHOc" height="1" width="1"/> http://dotnettipoftheday.org/tips/6B66433D-82AD-4F29-96DA-9AEA1EDD8484.aspx Fri, 14 Dec 2007 19:12:44 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=6B66433D-82AD-4F29-96DA-9AEA1EDD8484 Easily convert string to Proper Case <p>This is a string helper that converts string to a proper case (capitalized first letter of each word)</p> <p>Ex:<br />this is a test of proper case</p> <p>Result:<br />This Is A Test Of Proper Case</p> <p>Instead of using/creating a custom static method to do this, we just use built-in method of .NET though seldom use:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000ff;">using</span> System.Globalization;</p> <p style="margin: 0px;"><span style="color: #0000ff;">using</span> System.Threading;</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> ProperCase(<span style="color: #0000ff;">string</span> text)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TextInfo textInfo = cultureInfo.TextInfo;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">return</span> textInfo.ToTitleCase(text);</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> </div> <p>and use it like:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000ff;">string</span> properCase = ProperCase(<span style="color: #a31515;">"make me complete"</span>);</p> </div> <p>That's all there is to convert our string to proper case.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="N/A" style="font-weight:bold">Earljon Hidalgo</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vAyagfwCno0:rzu-XpEXxxQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=vAyagfwCno0:rzu-XpEXxxQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vAyagfwCno0:rzu-XpEXxxQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=vAyagfwCno0:rzu-XpEXxxQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vAyagfwCno0:rzu-XpEXxxQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=vAyagfwCno0:rzu-XpEXxxQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vAyagfwCno0:rzu-XpEXxxQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=vAyagfwCno0:rzu-XpEXxxQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=vAyagfwCno0:rzu-XpEXxxQ:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/vAyagfwCno0" height="1" width="1"/> http://dotnettipoftheday.org/tips/1010CF53-D307-41CE-B622-6DD68C5D3D7E.aspx Sun, 09 Dec 2007 15:17:35 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=1010CF53-D307-41CE-B622-6DD68C5D3D7E Referencing global namespace root <p>When you have something like:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">using</span> System;</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;"><span style="color: #0000FF">class</span> MyApp</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">public</span> <span style="color: #0000FF">class</span> System { } <span style="color: #008200">// redefine a known namespace. </span></p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">static</span> <span style="color: #0000FF">void</span> Main()</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Console.WriteLine(<span style="color: #a31515">"console test"</span>); <span style="color: #008200">// Error accesses MyApp.Console </span></p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.Console.WriteLine(<span style="color: #a31515">"console test"</span>); <span style="color: #008200">// Error accesses MyApp.Console </span></p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">}</p> <p style="margin: 0px;">&nbsp;</p> </div> </div> <p>You will confuse the compiler. To make it work you can rename your conflicting object, or use the "global" keyword, as in:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;">global::System.Console.WriteLine(<span style="color: #a31515;">"console test"</span>);</p> </div><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">M.Parreira</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Vo_ktR56yM4:WZybCeydTw0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Vo_ktR56yM4:WZybCeydTw0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Vo_ktR56yM4:WZybCeydTw0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Vo_ktR56yM4:WZybCeydTw0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Vo_ktR56yM4:WZybCeydTw0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Vo_ktR56yM4:WZybCeydTw0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Vo_ktR56yM4:WZybCeydTw0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=Vo_ktR56yM4:WZybCeydTw0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=Vo_ktR56yM4:WZybCeydTw0:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/Vo_ktR56yM4" height="1" width="1"/> http://dotnettipoftheday.org/tips/9EAC9792-B74F-4BEA-A728-D2692AE5CB4A.aspx Thu, 29 Nov 2007 20:13:31 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=9EAC9792-B74F-4BEA-A728-D2692AE5CB4A Add Grid &amp; SqlDataSource by hust Copy &amp; Paste <p>Copy one or more columns from a table in SQL Server 2005 diagrams and paste them in asp.net page, you see, Visual Studio creates a SqlDataSource & GridView for selecting and displaying those columns from that table.</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Hossein Margani</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mHgdBmUoYas:k1wl3RGZdws:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mHgdBmUoYas:k1wl3RGZdws:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mHgdBmUoYas:k1wl3RGZdws:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mHgdBmUoYas:k1wl3RGZdws:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mHgdBmUoYas:k1wl3RGZdws:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mHgdBmUoYas:k1wl3RGZdws:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mHgdBmUoYas:k1wl3RGZdws:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mHgdBmUoYas:k1wl3RGZdws:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mHgdBmUoYas:k1wl3RGZdws:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/mHgdBmUoYas" height="1" width="1"/> http://dotnettipoftheday.org/tips/FF23DBE9-5922-472D-9284-E3B7821EBC09.aspx Fri, 23 Nov 2007 18:46:00 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=FF23DBE9-5922-472D-9284-E3B7821EBC09 Build for larger projects <p>Hide the image folder and the other unnecessary folders and then compile your project.</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">SaSSi</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S-5PjtM3KDs:vzOt5R8ZOmo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=S-5PjtM3KDs:vzOt5R8ZOmo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S-5PjtM3KDs:vzOt5R8ZOmo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=S-5PjtM3KDs:vzOt5R8ZOmo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S-5PjtM3KDs:vzOt5R8ZOmo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=S-5PjtM3KDs:vzOt5R8ZOmo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S-5PjtM3KDs:vzOt5R8ZOmo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S-5PjtM3KDs:vzOt5R8ZOmo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=S-5PjtM3KDs:vzOt5R8ZOmo:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/S-5PjtM3KDs" height="1" width="1"/> http://dotnettipoftheday.org/tips/D8963D32-4ABD-4BF2-AC8D-1AADAE95EE3F.aspx Wed, 21 Nov 2007 03:58:15 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=D8963D32-4ABD-4BF2-AC8D-1AADAE95EE3F Quick class refactoring (Extracting methods) <p>When refactoring classes, you can quickly extract code into a new method by selecting the lines of code and using the <code style="color:teal">CTRL R</code> + <code style="color:teal">CTRL M</code> (Extract method) keyboard shortcut. Visual Studio will automatically work out the scope, return type and the parameter list and allow you to enter a new name for the method.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://mrez.spaces.live.com/" style="font-weight:bold">Stephen Els</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=BvvbVGNIQ2I:0hJP8abvNl4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=BvvbVGNIQ2I:0hJP8abvNl4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=BvvbVGNIQ2I:0hJP8abvNl4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=BvvbVGNIQ2I:0hJP8abvNl4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=BvvbVGNIQ2I:0hJP8abvNl4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=BvvbVGNIQ2I:0hJP8abvNl4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=BvvbVGNIQ2I:0hJP8abvNl4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=BvvbVGNIQ2I:0hJP8abvNl4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=BvvbVGNIQ2I:0hJP8abvNl4:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/BvvbVGNIQ2I" height="1" width="1"/> http://dotnettipoftheday.org/tips/3475DF18-7147-48A1-9EF5-53C8F90AEA0D.aspx Tue, 06 Nov 2007 16:38:33 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=3475DF18-7147-48A1-9EF5-53C8F90AEA0D How to read GPS metadata from image <p>In order to read GPS (or any other) metadata from image, you can use two new objects, introduces in .NET 3.0, named BitmapMetadata and BitmapDecoder. Following code returns Geolocation coordinates of pictures, taken by camera, that supports it</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">using</span> (Stream stream = <span style="color: #0000FF">new</span> FileStream(fileName, FileMode.Open, FileAccess.Read))</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; JpegBitmapDecoder decoder = <span style="color: #0000FF">new</span> JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.None);</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; BitmapMetadata meta = (BitmapMetadata)decoder.Frames[0].Metadata;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">ulong</span>[] latitude = meta.GetQuery(<span style="color: #a31515">"/app1/ifd/gps/subifd:{ulong=2}"</span>) <span style="color: #0000FF">as</span> <span style="color: #0000FF">ulong</span>[];</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">ulong</span>[] longitude = meta.GetQuery(<span style="color: #a31515">"/app1/ifd/gps/subifd:{ulong=4}"</span>) <span style="color: #0000FF">as</span> <span style="color: #0000FF">ulong</span>[];</p> <p style="margin: 0px;">}</p> </div> <p>Now you should convert retrived coordinates into it's readable represenation. You can do it, by using following method.</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">static</span> <span style="color: #0000FF">double</span> ConvertCoordinate(<span style="color: #0000FF">ulong</span>[] coordinates)</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">int</span> lDash = (<span style="color: #0000FF">int</span>)(coordinates[0] - ((<span style="color: #0000FF">ulong</span>)0x100000000));</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">int</span> lF = (<span style="color: #0000FF">int</span>)(coordinates[1] - ((<span style="color: #0000FF">ulong</span>)0x100000000));</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">double</span> lR = ((<span style="color: #0000FF">double</span>)(coordinates[2] - ((<span style="color: #0000FF">ulong</span>)0x6400000000))) / 100;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">double</span> tRes = (lDash + (((<span style="color: #0000FF">double</span>)lF) / 60)) + (lR / 3600);</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> (Math.Floor((<span style="color: #0000FF">double</span>)(tRes * 1000000)) / 1000000);</p> <p style="margin: 0px;">}</p> </div><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://blogs.microsoft.co.il/blogs/tamir" style="font-weight:bold">Tamir Khason</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=zW0TK1p0L5g:aFaJZbuxfyI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=zW0TK1p0L5g:aFaJZbuxfyI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=zW0TK1p0L5g:aFaJZbuxfyI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=zW0TK1p0L5g:aFaJZbuxfyI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=zW0TK1p0L5g:aFaJZbuxfyI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=zW0TK1p0L5g:aFaJZbuxfyI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=zW0TK1p0L5g:aFaJZbuxfyI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=zW0TK1p0L5g:aFaJZbuxfyI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=zW0TK1p0L5g:aFaJZbuxfyI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/zW0TK1p0L5g" height="1" width="1"/> http://dotnettipoftheday.org/tips/8341388E-432B-4B78-8298-31A34640C16A.aspx Sat, 03 Nov 2007 12:46:35 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=8341388E-432B-4B78-8298-31A34640C16A Check whether executable is managed <p>In order to check wherer dll or any other executable, you want to load by using reflection is managed, you should check file version signature</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">string</span> GetRuntimeVersion(<span style="color: #0000FF">string</span> filename)</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">const</span> <span style="color: #0000FF">int</span> CCH = 0x400;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; StringBuilder sb = <span style="color: #0000FF">new</span> StringBuilder(CCH);</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">int</span> len;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">int</span> hr = GetFileVersion(filename, sb, sb.Capacity, <span style="color: #0000FF">out</span> len);</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">if</span> (hr == <span style="color: #0000FF">unchecked</span>((<span style="color: #0000FF">int</span>)0x8007000B))</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> <span style="color: #0000FF">string</span>.Empty;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">else</span> <span style="color: #0000FF">if</span> (hr &lt; 0)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">throw</span> <span style="color: #0000FF">new</span> Win32Exception(hr);</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">else</span></p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> sb.ToString(0, len - 1);</p> <p style="margin: 0px;">}</p> </div> <p>Here is the signature of GetFileVersion method</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;">[DllImport(<span style="color: #a31515">"mscoree.dll"</span>)]</p> <p style="margin: 0px;"><span style="color: #0000FF">private</span> <span style="color: #0000FF">static</span> <span style="color: #0000FF">extern</span> <span style="color: #0000FF">int</span> GetFileVersion( [MarshalAs(UnmanagedType.LPWStr)] <span style="color: #0000FF">string</span> szFilename, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder szBuffer, <span style="color: #0000FF">int</span> cchBuffer, <span style="color: #0000FF">out</span> <span style="color: #0000FF">int</span> dwLength);</p> </div> <p>If the assebly is not managed, the method returns COR_E_ASSEMBLYEXPECTED, else the runtime verion, this assembly was compiled.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://blogs.microsoft.co.il/blogs/tamir/" style="font-weight:bold">Tamir Khason</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=CMEtDNd_oJs:-OVRjBZQeIQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=CMEtDNd_oJs:-OVRjBZQeIQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=CMEtDNd_oJs:-OVRjBZQeIQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=CMEtDNd_oJs:-OVRjBZQeIQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=CMEtDNd_oJs:-OVRjBZQeIQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=CMEtDNd_oJs:-OVRjBZQeIQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=CMEtDNd_oJs:-OVRjBZQeIQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=CMEtDNd_oJs:-OVRjBZQeIQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=CMEtDNd_oJs:-OVRjBZQeIQ:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/CMEtDNd_oJs" height="1" width="1"/> http://dotnettipoftheday.org/tips/32A285EA-75F4-4ED1-B5ED-82D8A1F2E98C.aspx Sat, 03 Nov 2007 12:41:11 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=32A285EA-75F4-4ED1-B5ED-82D8A1F2E98C Disable Submit button before its Click event <p>While submitting the form data to a server to be handled by the Click event of Submit button, it would be a good practice to disable the button. Here is a small code sample to achieve this by using the ClientScriptManager.GetPostBackEventReference method.</p> <p>VB.NET:</p> <p>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />&nbsp;&nbsp;&nbsp; btnSubmit.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(btnSubmit, "") &amp; ";this.value='Submitting...'; this.disabled = true;")<br />End Sub</p> <p>C#:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">protected</span> <span style="color: #0000FF">void</span> Page_Load(<span style="color: #0000FF">object</span> sender, System.EventArgs e)</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; btnSubmit.Attributes.Add(<span style="color: #a31515">"onclick"</span>, ClientScript.GetPostBackEventReference(btnSubmit, <span style="color: #a31515">""</span>) + <span style="color: #a31515">";this.value='Submitting...';this.disabled = true;"</span>);</p> <p style="margin: 0px;">}</p> </div><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Mustafa Basgun</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=lXREuuGbfNA:hifT7nTFFY0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=lXREuuGbfNA:hifT7nTFFY0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=lXREuuGbfNA:hifT7nTFFY0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=lXREuuGbfNA:hifT7nTFFY0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=lXREuuGbfNA:hifT7nTFFY0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=lXREuuGbfNA:hifT7nTFFY0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=lXREuuGbfNA:hifT7nTFFY0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=lXREuuGbfNA:hifT7nTFFY0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=lXREuuGbfNA:hifT7nTFFY0:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/lXREuuGbfNA" height="1" width="1"/> http://dotnettipoftheday.org/tips/85E540D8-E21A-4078-ADDD-AFCF363CA9B0.aspx Fri, 02 Nov 2007 00:34:17 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=85E540D8-E21A-4078-ADDD-AFCF363CA9B0 Publish RSS with the XML Control <p>The RSS control is a control that combines other controls and techniques so that you can publish RSS feed on a Web form. It uses the ASP.NET XML control, which takes the RSS feed as its input and runs it through XSLT style sheet. You can test RSS control on different feeds, ie RSS v1.0 and RSS v2.0 feeds. The version really doesn't matter because the XML is translated via the XSLT style sheet. If you need to support another RSS version, you can do so by modifying the XSLT style sheet.</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Lohith Bandrehalli</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JiOvtUeq_Dw:QxvD2REwNx0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JiOvtUeq_Dw:QxvD2REwNx0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JiOvtUeq_Dw:QxvD2REwNx0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JiOvtUeq_Dw:QxvD2REwNx0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JiOvtUeq_Dw:QxvD2REwNx0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JiOvtUeq_Dw:QxvD2REwNx0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JiOvtUeq_Dw:QxvD2REwNx0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=JiOvtUeq_Dw:QxvD2REwNx0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=JiOvtUeq_Dw:QxvD2REwNx0:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/JiOvtUeq_Dw" height="1" width="1"/> http://dotnettipoftheday.org/tips/7F71159D-BA22-4759-84BF-6E89AA5E3784.aspx Thu, 01 Nov 2007 21:16:12 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=7F71159D-BA22-4759-84BF-6E89AA5E3784 Windows Forms Versus WPF <p>Windows Forms is legacy. Microsoft should label Windows Forms as legacy (as it has done with COM), only offer bug fixes and concentrate 100% on WPF. WPF is the future. I&rsquo;ve had more fun building WPF UI than I&rsquo;ve ever had with Windows Forms. Ignoring the WPF fun element, I think the WPF applications I&rsquo;ve build are far superior to anything I did in Windows Forms from the perspective of usability and visualization of data. Here are a few advantages to using WPF:</p> <ul> <li>Databinding in WPF is superior to what Windows Forms offers.</li> <li>UI and C# business logic can be cleanly separated in WPF.</li> <li>Storyboard.</li> <li>Data/control templates - a much cleaner way than anything Windows Forms can offer. Styles - cool and simple. Its so easy to style all your buttons in an application to have the same look and feel.</li> <li>Even if the VS designer breaks, its easy to code XAML.</li> <li>UI virtualization.</li> <li>I&rsquo;ve got grids with 100K rows, ticking off a moving market. Performance would be dreadful if it wasn&rsquo;t for UI visualization which come for free.</li> <li>3D support.</li> <li>Nothing scientific but, UI development feels quicker in WPF - maybe its just because a WPF application looks cooler at the end of an iteration, or maybe its because development really is quicker. I can add a User Experience engineer to my team, and with no C# knowledge he can work magic in Expression Blend and give the front-office trading application a makeover that is guaranteed to win over the business users.</li> </ul><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://sheths.spaces.live.com" style="font-weight:bold">Jigar</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mR1Q5kMQ2rU:lN__7L4cAAw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mR1Q5kMQ2rU:lN__7L4cAAw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mR1Q5kMQ2rU:lN__7L4cAAw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mR1Q5kMQ2rU:lN__7L4cAAw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mR1Q5kMQ2rU:lN__7L4cAAw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mR1Q5kMQ2rU:lN__7L4cAAw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mR1Q5kMQ2rU:lN__7L4cAAw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=mR1Q5kMQ2rU:lN__7L4cAAw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=mR1Q5kMQ2rU:lN__7L4cAAw:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/mR1Q5kMQ2rU" height="1" width="1"/> http://dotnettipoftheday.org/tips/C5EC2C61-A6BE-4231-BE69-76AD02B3E819.aspx Wed, 31 Oct 2007 09:30:14 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=C5EC2C61-A6BE-4231-BE69-76AD02B3E819 The System.Data.Design Namespace <p>The System.Data.Design namespace, is the smallest of the ADO.NET namespaces, which contains classes used to create typed DataSet classes, including code and parameters. This namespace is new to the .NET Framework 2.0, but the classes in this namespace were located in the System.Data namespace in previous versions of the .NET Framework. The classes are mostly used internally by ADO.NET-related functionality i.e. exposed in the Visual Studio .NET IDE, such as creating a typed DataSet from a DataAdapter dragged from the toolbox and dropped on the designer.</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Lohith Bandrehalli</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZssA5nLEClE:jnwYdLk1zQM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZssA5nLEClE:jnwYdLk1zQM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZssA5nLEClE:jnwYdLk1zQM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZssA5nLEClE:jnwYdLk1zQM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZssA5nLEClE:jnwYdLk1zQM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZssA5nLEClE:jnwYdLk1zQM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZssA5nLEClE:jnwYdLk1zQM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZssA5nLEClE:jnwYdLk1zQM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZssA5nLEClE:jnwYdLk1zQM:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/ZssA5nLEClE" height="1" width="1"/> http://dotnettipoftheday.org/tips/2B6C6884-F56B-4679-9F12-9C2B9FB16553.aspx Wed, 31 Oct 2007 06:36:05 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=2B6C6884-F56B-4679-9F12-9C2B9FB16553 Which is better: Control or WebControl? <p>The Control class in System.Web.UI namespace is the base class for all server controls. This provides the properties, methods, and events shared by all web controls. The WebControl class in System.Web.UI.WebControls namespace derives from the Control class and adds style properties such as Font, Forecolor, and Backcolor. Microsoft recommends if your custom control contains no user interface elements then derive from Control Class. if your custom control provides a user interface, then derive from WebControl class.</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Lohith Bandrehalli</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZQ5CueH4x4M:Z4qvvlSKYLk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZQ5CueH4x4M:Z4qvvlSKYLk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZQ5CueH4x4M:Z4qvvlSKYLk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZQ5CueH4x4M:Z4qvvlSKYLk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZQ5CueH4x4M:Z4qvvlSKYLk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZQ5CueH4x4M:Z4qvvlSKYLk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZQ5CueH4x4M:Z4qvvlSKYLk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=ZQ5CueH4x4M:Z4qvvlSKYLk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=ZQ5CueH4x4M:Z4qvvlSKYLk:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/ZQ5CueH4x4M" height="1" width="1"/> http://dotnettipoftheday.org/tips/009963A2-0E10-42BD-820C-737A8886460A.aspx Tue, 30 Oct 2007 07:34:07 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=009963A2-0E10-42BD-820C-737A8886460A Handling Errors at the Method Level <ol> <li>If potential errors are recoverable in the routine Use a combination of try&hellip;Catch blocks as a retry mechanism for error handling.</li> <li>If useful information can be added to the exception Create and throw a new exception with the added information.</li> <li>If cleanup is required Perform it in the finally block.</li> <li>If potential errors are not recoverable in the routine Recovery should be handled by the calling routine and its error-handling structure.</li> </ol><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">Lohith Bandrehalli</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=LqudOI_aw-s:Guh7U5NjRuI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=LqudOI_aw-s:Guh7U5NjRuI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=LqudOI_aw-s:Guh7U5NjRuI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=LqudOI_aw-s:Guh7U5NjRuI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=LqudOI_aw-s:Guh7U5NjRuI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=LqudOI_aw-s:Guh7U5NjRuI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=LqudOI_aw-s:Guh7U5NjRuI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=LqudOI_aw-s:Guh7U5NjRuI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=LqudOI_aw-s:Guh7U5NjRuI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/LqudOI_aw-s" height="1" width="1"/> http://dotnettipoftheday.org/tips/8341909A-A106-4CC5-B5A2-9DB545DBC8F3.aspx Fri, 26 Oct 2007 08:29:31 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=8341909A-A106-4CC5-B5A2-9DB545DBC8F3 Reading and Writing the Registry <p>To write to the registry use Registry.SetValue()</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">string</span> keyname = <span style="color: #a31515">"HKEY_CURRENT_USER\\Software\\CompanyName\\AppName"</span>;</p> <p style="margin: 0px;">Registry.SetValue(keyname, <span style="color: #a31515">"TestString"</span>, <span style="color: #a31515">"Hello"</span>);</p> </div> <p>To read the registry use Registry.GetValue()</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #008200">// default to blank if not present </span></p> <p style="margin: 0px;"><span style="color: #0000FF">string</span> s = Registry.GetValue(keyname, <span style="color: #a31515">"TestString"</span>, <span style="color: #a31515">""</span>).ToString();&nbsp;</p> </div><p style="font-style:italic; margin-top:20px;">submitted by <a href="briankowald.com" style="font-weight:bold">Brian Kowald</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=A1b-ZOiDSXw:g8AcPJP57Dc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=A1b-ZOiDSXw:g8AcPJP57Dc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=A1b-ZOiDSXw:g8AcPJP57Dc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=A1b-ZOiDSXw:g8AcPJP57Dc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=A1b-ZOiDSXw:g8AcPJP57Dc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=A1b-ZOiDSXw:g8AcPJP57Dc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=A1b-ZOiDSXw:g8AcPJP57Dc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=A1b-ZOiDSXw:g8AcPJP57Dc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=A1b-ZOiDSXw:g8AcPJP57Dc:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/A1b-ZOiDSXw" height="1" width="1"/> http://dotnettipoftheday.org/tips/3723EF0D-7176-4020-9AF9-7C4A39E8DE5A.aspx Thu, 25 Oct 2007 20:19:03 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=3723EF0D-7176-4020-9AF9-7C4A39E8DE5A Writting to Windows Application Log <p>To write to the windows application log use this:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">using</span> System.Diagnostics;</p> <p style="margin: 0px;">&nbsp;</p> <p style="margin: 0px;">...</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp;</p> <p style="margin: 0px;">EventLog elog = <span style="color: #0000FF">new</span> EventLog();</p> <p style="margin: 0px;">elog.Log = <span style="color: #a31515">"Application"</span>;</p> <p style="margin: 0px;">elog.Source = <span style="color: #a31515">"My test log program"</span>;</p> <p style="margin: 0px;">elog.WriteEntry(<span style="color: #a31515">"Hello, World"</span>);</p> <p style="margin: 0px;">elog.Close();</p> </div><p style="font-style:italic; margin-top:20px;">submitted by <a href="briankowald.com" style="font-weight:bold">Brian Kowald</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S7nxXjFSn3o:4Ii9mcHDVM4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=S7nxXjFSn3o:4Ii9mcHDVM4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S7nxXjFSn3o:4Ii9mcHDVM4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=S7nxXjFSn3o:4Ii9mcHDVM4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S7nxXjFSn3o:4Ii9mcHDVM4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=S7nxXjFSn3o:4Ii9mcHDVM4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S7nxXjFSn3o:4Ii9mcHDVM4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=S7nxXjFSn3o:4Ii9mcHDVM4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=S7nxXjFSn3o:4Ii9mcHDVM4:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/S7nxXjFSn3o" height="1" width="1"/> http://dotnettipoftheday.org/tips/161315BA-83FA-4C28-9023-51B123637BEB.aspx Thu, 25 Oct 2007 20:11:11 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=161315BA-83FA-4C28-9023-51B123637BEB Move hard-coded strings to a Resource <p>With <a href="http://www.codeplex.com/ResourceRefactoring">this</a> light VS add-in, you can move hard-coded strings to resource files easily. All you have to do is:</p> <ul> <li>right click on the string</li> <li>refactor &gt; extract to resource</li> <li>select an existing resource or type a new resource name on the opened window</li> </ul> <p>Using resource files is strongly recommended in .NET applications. For example, strings can be loaded faster and can be translated to other languages.</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.tahiroglu.com" style="font-weight:bold">Muhammed Tahiroglu</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tnm0cO71-sw:iwwZ32ePZxo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=tnm0cO71-sw:iwwZ32ePZxo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tnm0cO71-sw:iwwZ32ePZxo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=tnm0cO71-sw:iwwZ32ePZxo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tnm0cO71-sw:iwwZ32ePZxo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=tnm0cO71-sw:iwwZ32ePZxo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tnm0cO71-sw:iwwZ32ePZxo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=tnm0cO71-sw:iwwZ32ePZxo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=tnm0cO71-sw:iwwZ32ePZxo:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/tnm0cO71-sw" height="1" width="1"/> http://dotnettipoftheday.org/tips/66F47DFF-D2E1-40B0-80B2-0305CD31AB67.aspx Thu, 25 Oct 2007 17:42:10 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=66F47DFF-D2E1-40B0-80B2-0305CD31AB67 Find a control within a control recursively <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">public</span> Control FindControlRecursive(Control Root, <span style="color: #0000FF">string</span> Id)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">if</span> (Root.ID == Id)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> Root;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">foreach</span> (Control Ctl <span style="color: #0000FF">in</span> Root.Controls)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Control FoundCtl = FindControlRecursive(Ctl, Id);</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">if</span> (FoundCtl != <span style="color: #0000FF">null</span>)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> FoundCtl;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> <span style="color: #0000FF">null</span>;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #008200">//Example Usage </span></p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; Label myLabel = (Label)FindControlRecursive(Page, <span style="color: #a31515">"myLabel"</span>);</p> </div><p style="font-style:italic; margin-top:20px;">submitted by <a href="www.calistomind.com" style="font-weight:bold">Jesal Gadhia</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=QFIPbjqJRTE:xxbIoEBIcX8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=QFIPbjqJRTE:xxbIoEBIcX8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=QFIPbjqJRTE:xxbIoEBIcX8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=QFIPbjqJRTE:xxbIoEBIcX8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=QFIPbjqJRTE:xxbIoEBIcX8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=QFIPbjqJRTE:xxbIoEBIcX8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=QFIPbjqJRTE:xxbIoEBIcX8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=QFIPbjqJRTE:xxbIoEBIcX8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=QFIPbjqJRTE:xxbIoEBIcX8:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/QFIPbjqJRTE" height="1" width="1"/> http://dotnettipoftheday.org/tips/0C9EEF26-B6D2-45D3-A425-46225FFBB3F9.aspx Sat, 20 Oct 2007 11:56:18 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=0C9EEF26-B6D2-45D3-A425-46225FFBB3F9 How to call a surrogate for Dispose() on StringBuilder objects <p>A typical use for the StringBuilder type looks like below:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000ff;">class</span> Program</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> UseStringBuilder(<span style="color: #0000ff;">string</span> token)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; StringBuilder sb = <span style="color: #0000ff;">new</span> StringBuilder();</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">int</span> i = 10;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">while</span> (i-- &gt; 0)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sb.Append(token + '\n');</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">string</span> result = sb.ToString();</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">return</span> result;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> Main(<span style="color: #0000ff;">string</span>[] args)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Console.WriteLine(ShowContent(<span style="color: #a31515;">"first"</span>));</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Console.WriteLine(ShowContent(<span style="color: #a31515;">"second"</span>));</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">}</p> </div> <p>The issue with this code is that when sb goes out of scope it is mark for garbage collection, but the memory stored in it lingers until the garbage collector invokes its finalizer. That could amount to a lot of unused memory and hence might cost you some unnecessary garbage collections by the CLR. Given this behavior it would only look natural to call something like Dispose to take care of the underline memory buffer used in the StringBuilder. Unfortunately there is no Dispose method for this class, or any method to hint at freeing this unused memory in a deterministic way. The trick to get rid of this memory without invoking the finalizer is to set the Length to 0. The efficient code will become:</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000FF">class</span> Program</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">static</span> <span style="color: #0000FF">string</span> UseStringBuilder (<span style="color: #0000FF">string</span> token)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; StringBuilder sb = <span style="color: #0000FF">new</span> StringBuilder();</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">int</span> i = 10;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">while</span> (i-- &gt; 0)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sb.Append(token + '\n');</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">string</span> result = sb.ToString();</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sb.Length = 0;<span style="color: #008200">// this is the Dispose equivalent </span></p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000FF">return</span> result;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp;</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: #0000FF">static</span> <span style="color: #0000FF">void</span> Main(<span style="color: #0000FF">string</span>[] args)</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Console.WriteLine(ShowContent(<span style="color: #a31515">"first"</span>)); <span style="color: #008200">// no need to call System.GC.Collect() for the unreferenced StringBuilder object </span></p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Console.WriteLine(ShowContent(<span style="color: #a31515">"second"</span>));</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p> <p style="margin: 0px;">}&nbsp;</p> </div><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.codeproject.com/script/articles/list_articles.asp?userid=634640" style="font-weight:bold">decebal mihailescu</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=5sbM7kcO-wI:g7wowxSwdX0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=5sbM7kcO-wI:g7wowxSwdX0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=5sbM7kcO-wI:g7wowxSwdX0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=5sbM7kcO-wI:g7wowxSwdX0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=5sbM7kcO-wI:g7wowxSwdX0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=5sbM7kcO-wI:g7wowxSwdX0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=5sbM7kcO-wI:g7wowxSwdX0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=5sbM7kcO-wI:g7wowxSwdX0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=5sbM7kcO-wI:g7wowxSwdX0:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/5sbM7kcO-wI" height="1" width="1"/> http://dotnettipoftheday.org/tips/F43E5E76-614C-411C-ADA4-62B7E20F4D12.aspx Sat, 20 Oct 2007 00:10:51 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=F43E5E76-614C-411C-ADA4-62B7E20F4D12 How to maintain the position of the scrollbar on postbacks (across the entire site) <p>In ASP.NET 1.1 it was a pain to maintain the position of the scrollbar when doing a postback operation. In ASP.NET 2.0 you can simply add the MaintainScrollPostionOnPostBack attribute to the Page directive of any specific page:</p> <p>&lt;% Page Language="C#" ... MaintainScrollPositionOnPostback="true" %&gt;&nbsp;</p> <p>If you would like to apply this behavior to your entire site simply modify the &lt;pages /&gt; entry of your &lt;system.web /&gt; section in your web.config file like so:</p> <p>&lt;pages maintainScrollPositionOnPostBack="true"&gt;</p><p style="font-style:italic; margin-top:20px;">submitted by <a href="http://www.JoeLevi.com" style="font-weight:bold">Joe Levi</a></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=TpbukEBfsFA:YL18m7g8ea0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=TpbukEBfsFA:YL18m7g8ea0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=TpbukEBfsFA:YL18m7g8ea0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=TpbukEBfsFA:YL18m7g8ea0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=TpbukEBfsFA:YL18m7g8ea0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=TpbukEBfsFA:YL18m7g8ea0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=TpbukEBfsFA:YL18m7g8ea0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=TpbukEBfsFA:YL18m7g8ea0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=TpbukEBfsFA:YL18m7g8ea0:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/TpbukEBfsFA" height="1" width="1"/> http://dotnettipoftheday.org/tips/C7891B11-D3A9-4E79-BA2D-66B2557F76DB.aspx Wed, 03 Oct 2007 00:12:28 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=C7891B11-D3A9-4E79-BA2D-66B2557F76DB Enum.IsDefined() to check submited user values <p>Given an enum like...</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">enum</span> MyEnum</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; Value1,</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; Value2,</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; Value3</p> <p style="margin: 0px;">}</p> </div> <p>When you have a user submited value you need to check against an enum, you can easilly do it..</p> <div style="font-family: Courier New; font-size: 10pt; color: #000000"> <p style="margin: 0px;"><span style="color: #0000ff;">int</span> submitedValue = 123;</p> <p style="margin: 0px;"><span style="color: #0000ff;">if</span>(Enum.IsDefined(<span style="color: #0000ff;">typeof</span>(MyEnum), submitedValue))</p> <p style="margin: 0px;">{</p> <p style="margin: 0px;">&nbsp;&nbsp;&nbsp; ...</p> </div> <p>&nbsp;</p><p style="font-style:italic; margin-top:20px;">submitted by <span style="font-weight:bold">M.Parreira</span></p><div class="feedflare"> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8sF4N5JJTt0:YOTE9yODbaI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=8sF4N5JJTt0:YOTE9yODbaI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8sF4N5JJTt0:YOTE9yODbaI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=8sF4N5JJTt0:YOTE9yODbaI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8sF4N5JJTt0:YOTE9yODbaI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=8sF4N5JJTt0:YOTE9yODbaI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8sF4N5JJTt0:YOTE9yODbaI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.dotnettipoftheday.org/~ff/netTipsTricksCommunity?a=8sF4N5JJTt0:YOTE9yODbaI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/netTipsTricksCommunity?i=8sF4N5JJTt0:YOTE9yODbaI:D7DqB2pKExk" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/netTipsTricksCommunity/~4/8sF4N5JJTt0" height="1" width="1"/> http://dotnettipoftheday.org/tips/89C66B6B-09DA-4CCF-B34B-37BCDF473A07.aspx Wed, 26 Sep 2007 18:27:17 GMT http://dotnettipoftheday.org/tips/CommentsRss.aspx?tipid=89C66B6B-09DA-4CCF-B34B-37BCDF473A07