<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Kobi's Weblog</title>
	<atom:link href="http://kobikobi.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://kobikobi.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 12 May 2009 20:34:55 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='kobikobi.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/e825295b3f53b016d78e9b1566d0ea2c?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Kobi's Weblog</title>
		<link>http://kobikobi.wordpress.com</link>
	</image>
			<item>
		<title>Adding Items to a SharePoint List</title>
		<link>http://kobikobi.wordpress.com/2009/05/04/adding-items-to-a-sharepoint-list/</link>
		<comments>http://kobikobi.wordpress.com/2009/05/04/adding-items-to-a-sharepoint-list/#comments</comments>
		<pubDate>Mon, 04 May 2009 15:23:06 +0000</pubDate>
		<dc:creator>Kobi</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[Permissions]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[SPItem]]></category>
		<category><![CDATA[SPList]]></category>
		<category><![CDATA[web part]]></category>

		<guid isPermaLink="false">http://kobikobi.wordpress.com/?p=144</guid>
		<description><![CDATA[Ok, a low-tech post this time. I&#8217;ve wasted the better part of my last few days battling Share Point permissions. My goal was to write a web part that lets users add an entry to a Share Point list. So, in case you (or me) need users to add items to a list, this could [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=144&subd=kobikobi&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Ok, a low-tech post this time. I&#8217;ve wasted the better part of my last few days battling Share Point permissions. My goal was to write a web part that lets users add an entry to a Share Point list. So, in case you (or me) need users to add items to a list, this could save us a lot of time&#8230;<br />
<span id="more-144"></span><br />
At first everything worked well, since I used a system account for testing. As expected, when switching to a regular user I started getting errors:</p>
<ol>
<li><strong>Access Denied</strong> &#8211; At first I received SharePoint&#8217;s Access Denied page. I soon remembered I had to elevate the permissions (lambda style).</li>
<li><strong>Another Access Denied</strong> &#8211; Even after using RunWithElevatedPrivileges, <a href="http://www.mikhaildikov.com/2007/07/runwithelevatedprivileges-watch-out-for.html">we have to reopen our SPSite and SPWeb</a>, we can&#8217;t use SPContext (it has the old permissions). Which is a shame, because we also have to close them later (here this is done with using, but in the real code I manage it on another class).</li>
<li><strong>Security Validation Exception</strong> &#8211; This one took me a few hours. When searching for the answer I saw someone <a href="http://blogs.msdn.com/mpoulson/archive/2005/12/02/499504.aspx">suggesting to use AllowUnsafeUpdates</a> (which a colleague said I should use on a different project). That means setting &#8220;web.AllowUnsafeUpdates = true;&#8221; before I make any updates, and setting it back to false later.<br />
<code>Microsoft.SharePoint.SPException:<br />
The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. ---&gt;<br />
System.Runtime.InteropServices.COMException (0x8102006D): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.<br />
</code>
</li>
<li><strong>ValidateFormDigest</strong> &#8211; While commenting the code I realized I don&#8217;t fully understand what AllowUnsafeUpdates does and why I use it. I came across a very detailed article, that explained I could <a href="http://hristopavlov.wordpress.com/2008/05/16/what-you-need-to-know-about-allowunsafeupdates/">use ValidateFormDigest</a> instead of this little hack.</li>
</ol>
<p>Sample code for users adding or updating an item:</p>
<pre class="brush: csharp;">
//A user cannot add items, needs elevated permissions.
SPSecurity.RunWithElevatedPrivileges(() =&gt;
{
  //when using RunWithElevatedPrivileges we cannot use
  // SPContext.Current - These SP objects have the old
  // privileges. We need to open a new SPSite and SPWeb.
  using (SPSite site = new SPSite(SPContext.Current.Site.ID))
  {
    using (SPWeb web = site.OpenWeb(&quot;/training&quot;))
    {
      //Validate form POST data.
      SPUtility.ValidateFormDigest();

      //demo code for adding or editing an item
      SPList registrations = web.Lists[&quot;Registrations&quot;];
      SPItem newItem = registrations.Items.Add();
      newItem[&quot;Title&quot;] = &quot;Added new Item&quot;;
      newItem.Update();
      //end of demo code.
    }
  }
});
</pre>
<p>Second option &#8211; stronger but more hacky:</p>
<pre class="brush: csharp;">
//A user cannot add items, needs elevated permissions.
SPSecurity.RunWithElevatedPrivileges(() =&gt;
{
  //when using RunWithElevatedPrivileges we cannot use
  // SPContext.Current - These SP objects have the old
  // privileges. We need to open a new SPSite and SPWeb.
  using (SPSite site = new SPSite(SPContext.Current.Site.ID))
  {
    using (SPWeb web = site.OpenWeb(&quot;/training&quot;))
    {
      web.AllowUnsafeUpdates = true;

      //code for adding or editing an item...

      web.AllowUnsafeUpdates = false;
    }
  }
});
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kobikobi.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kobikobi.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kobikobi.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kobikobi.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kobikobi.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kobikobi.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kobikobi.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kobikobi.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kobikobi.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kobikobi.wordpress.com/144/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=144&subd=kobikobi&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://kobikobi.wordpress.com/2009/05/04/adding-items-to-a-sharepoint-list/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd75cd399cd893182d6e3d06d738d6d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kobi</media:title>
		</media:content>
	</item>
		<item>
		<title>Sending Meeting Requests to Outlook via ASP.NET Mail Message</title>
		<link>http://kobikobi.wordpress.com/2009/01/03/sending-meeting-requests-to-outlook-via-aspnet-mail-message/</link>
		<comments>http://kobikobi.wordpress.com/2009/01/03/sending-meeting-requests-to-outlook-via-aspnet-mail-message/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 16:17:27 +0000</pubDate>
		<dc:creator>Kobi</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Appointment]]></category>
		<category><![CDATA[Attachment]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[ical]]></category>
		<category><![CDATA[ics]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[MailMessage]]></category>
		<category><![CDATA[Meeting]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://kobikobi.wordpress.com/?p=84</guid>
		<description><![CDATA[Numerous programs on my company deal with event registration. Naturally, that involves sending our employees meeting requests. Here&#8217;s the best way I&#8217;ve found so far for doing that. The long function at the end is from a web-service already in use for a few months.
To make these ICS files dynamically, I use the .Net library [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=84&subd=kobikobi&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Numerous programs on my company deal with event registration. Naturally, that involves sending our employees meeting requests. Here&#8217;s the best way I&#8217;ve found so far for doing that. The long function at the end is from a web-service already in use for a few months.</p>
<div id="attachment_100" class="wp-caption alignright" style="width: 360px"><img class="size-full wp-image-100" title="meeting_request" src="http://kobikobi.files.wordpress.com/2008/12/meeting_request.png?w=350&#038;h=75" alt="Meeting Request" width="350" height="75" /><p class="wp-caption-text">Meeting Request</p></div>
<p>To make these ICS files dynamically, I use the .Net library <a href="http://sourceforge.net/projects/dday-ical/">DDay.iCal</a>. It&#8217;s aewsome.<br />
It took some trial and error, but at the end I was able to create events that work well for all versions of Outlook.<br />
Unlike the solutions I&#8217;ve found on the web, this one doesn&#8217;t use the office interop thing, so I don&#8217;t need outlook installed on the server. I&#8217;m using a regular SMTP mail message and add the ICS as attachment. </p>
<p>Anyway, assuming you know how to send mails and how to generate the right ICS for your event (we&#8217;ll get to that later), this is the way to send it to Outlook:<br />
First the variables:</p>
<pre class="brush: csharp;">
//init the message with your defaults (from, to, subject, etc)
MailMessage message = initMailMessage();
string iCal = initICal(parameters ...);
</pre>
<p>And the code that adds the attachment:</p>
<pre class="brush: csharp;">
//Add the attachment, specify it is a calendar file.
System.Net.Mail.Attachment attachment =
System.Net.Mail.Attachment.CreateAttachmentFromString(
iCal, new ContentType(&quot;text/calendar&quot;));
attachment.TransferEncoding = TransferEncoding.Base64;
attachment.Name = &quot;EventDetails.ics&quot;; //not visible in outlook

message.Attachments.Add(attachment);

sendMailMessage(message);
</pre>
<p>Ok. That&#8217;s probably disappointing, since you can&#8217;t just copy-paste this code and make it work. I&#8217;m including more code you may want to use, but first some rules for the ICS files you&#8217;re about to create:</p>
<h4>Rules of Thumb</h4>
<ul>
<li>Make sure to specify the Method property &#8211; should be Publish or Request. Outlook won&#8217;t accept the file without it.</li>
<li>Add an Organizer &#8211; or Outlook 2007 won&#8217;t let people save the event.</li>
<li>Add the meeting&#8217;s subject and description to the ICS file, but also as the mail&#8217;s subject and body. Outlook may display either one.
</ul>
<p>Now for that extra code.<br />
This one is pretty simple &#8211; sends an SMTP message:</p>
<pre class="brush: csharp;">
private static void sendMailMessage(MailMessage mailMessage)
{
string mailHost = &quot;Ask.Someone.com&quot;;
SmtpClient smtpClient = new SmtpClient(mailHost, 25);
smtpClient.DeliveryMethod =
   SmtpDeliveryMethod.PickupDirectoryFromIis;
smtpClient.Send(mailMessage);
}
</pre>
<p>This fine function creates the ICS:</p>
<pre class="brush: csharp;">
[WebMethod(Description =
   &quot;Send an appointment with much details.&quot;)]
public void SendAppointment(string from, string to,
   string title, string body, DateTime startDate,
   double duration, string location, string organizer,
   bool updatePreviousEvent, string eventId,
   bool allDayEvent,
   int recurrenceDaysInterval, int recurrenceCount)
{
  iCalendar iCal = new iCalendar();

  // outlook 2003 needs this property,
  //  or we'll get an error (a Lunar error!)
  iCal.Method = &quot;PUBLISH&quot;;

  // Create the event
  Event evt = iCal.Create();

  evt.Summary = title;

  evt.Start = new iCalDateTime(startDate.Year,
    startDate.Month, startDate.Day, startDate.Hour,
    startDate.Minute, startDate.Second);
  evt.Duration = TimeSpan.FromHours(duration);
  evt.Description = body;
  evt.Location = location;

  if (recurrenceDaysInterval &amp;gt; 0)
  {
    RecurrencePattern rp = new RecurrencePattern();
    rp.Frequency = FrequencyType.Daily;
    rp.Interval = recurrenceDaysInterval; // interval of days

    rp.Count = recurrenceCount;
    evt.AddRecurrencePattern(rp);
  }
  evt.IsAllDay = allDayEvent;

  //organizer is mandatory for outlook 2007 - think about
  // trowing an exception here.
  if (!String.IsNullOrEmpty(organizer))
    evt.Organizer = organizer;

  if (!String.IsNullOrEmpty(eventId))
    evt.UID = eventId;

  //&quot;REQUEST&quot; will update an existing event with the same
  // UID (Unique ID) and a newer time stamp.
  if (updatePreviousEvent)
    iCal.Method = &quot;REQUEST&quot;;

  // Save into calendar file.
  iCalendarSerializer serializer =
    new iCalendarSerializer(iCal);
  //serializer.Serialize(@&quot;iCalendar.ics&quot;);

  string icalData = serializer.SerializeToString();

  //send the iCal data. Also sends the subject and body
  //on the mail.
  SendAppointmentFromICalWithMailTitle(from, to,
    icalData, title, body);
}
</pre>
<h4>See Also:</h4>
<ul>
<li><a href='http://sourceforge.net/projects/dday-ical'>DDay.iCal</a> &#8211; The iCal C# library.</li>
<li><a href='http://www.mavetju.org/programming/outlook-ics.php'>http://www.mavetju.org/programming/outlook-ics.php</a> &#8211; This helped at the beginning, but written in Perl. Which is weird.</li>
<li><a href='http://chuckdotnet.blogspot.com/2007/10/send-outlook-meeting-requests-with.html'>http://chuckdotnet.blogspot.com/2007/10/send-outlook-meeting-requests-with.html</a> &#8211; A VB.Net version, creating his own iCal and using Alternate Views.</li>
<li><a href='http://www.ietf.org/rfc/rfc2446.txt'>The iTip RFC &#8211; RFC 2446</a> &#8211; Had to read parts of it.</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kobikobi.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kobikobi.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kobikobi.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kobikobi.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kobikobi.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kobikobi.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kobikobi.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kobikobi.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kobikobi.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kobikobi.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=84&subd=kobikobi&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://kobikobi.wordpress.com/2009/01/03/sending-meeting-requests-to-outlook-via-aspnet-mail-message/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd75cd399cd893182d6e3d06d738d6d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kobi</media:title>
		</media:content>

		<media:content url="http://kobikobi.files.wordpress.com/2008/12/meeting_request.png" medium="image">
			<media:title type="html">meeting_request</media:title>
		</media:content>
	</item>
		<item>
		<title>How not to Code: The String Identity Function</title>
		<link>http://kobikobi.wordpress.com/2008/12/09/how-not-to-code-the-string-identity-function/</link>
		<comments>http://kobikobi.wordpress.com/2008/12/09/how-not-to-code-the-string-identity-function/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 07:19:59 +0000</pubDate>
		<dc:creator>Kobi</dc:creator>
				<category><![CDATA[How not to Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[Identity Function]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://kobikobi.wordpress.com/?p=86</guid>
		<description><![CDATA[Yesterday I started working on a small system that&#8217;s been having some problems lately. Reviewing the code, I quickly came across the following function:

public static string IsNullToString(string _str)
{
    string name = null;
    if (_str != null)
    {
        name = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=86&subd=kobikobi&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Yesterday I started working on a small system that&#8217;s been having some problems lately. Reviewing the code, I quickly came across the following function:</p>
<pre class="brush: csharp;">
public static string IsNullToString(string _str)
{
    string name = null;
    if (_str != null)
    {
        name = _str.ToString();
    }
    return name;
}
</pre>
<p>Now, it seems that if that function receives a null it returns a null, and for other string it&#8217;s returning that string. Remembering that String is a sealed class and cannot be inherited, and that String.ToString() does very little, I fail to see why this function is used every time a string is printed out, 108 times in the code&#8230;</p>
<p><strong>See Also:</strong></p>
<ul>
<li>
<a href="http://en.wikipedia.org/wiki/Identity_function">Identity Function from Wikipedia</a></li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kobikobi.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kobikobi.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kobikobi.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kobikobi.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kobikobi.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kobikobi.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kobikobi.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kobikobi.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kobikobi.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kobikobi.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=86&subd=kobikobi&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://kobikobi.wordpress.com/2008/12/09/how-not-to-code-the-string-identity-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd75cd399cd893182d6e3d06d738d6d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kobi</media:title>
		</media:content>
	</item>
		<item>
		<title>Using jQuery to Filter Table Rows</title>
		<link>http://kobikobi.wordpress.com/2008/09/15/using-jquery-to-filter-table-rows/</link>
		<comments>http://kobikobi.wordpress.com/2008/09/15/using-jquery-to-filter-table-rows/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 06:40:12 +0000</pubDate>
		<dc:creator>Kobi</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://kobikobi.wordpress.com/?p=56</guid>
		<description><![CDATA[I&#8217;m retouching an old system, and though it could use a filter on it&#8217;s report page. The report has a large table with about 300 rows. After some play with jQuery, I came out with this little filter.
The project is using the .net GridView control, so I had limited control over the output HTML code. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=56&subd=kobikobi&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;m retouching an old system, and though it could use a filter on it&#8217;s report page. The report has a large table with about 300 rows. After some play with <a href="http://jquery.com/">jQuery</a>, I came out with this little filter.<br />
The project is using the .net GridView control, so I had limited control over the output HTML code. Still, I think this code can work for most tables. One thing to notice: you should use the class &#8220;filterable&#8221; on your table or on one of its parents for the code to work.<br />
First, we need a text box:</p>
<pre class="brush: xml;">
Filter:
&lt;input type=&quot;text&quot; id=&quot;FilterTextBox&quot; name=&quot;FilterTextBox&quot; /&gt;
</pre>
<p>And the code:</p>
<pre class="brush: jscript;">
$(document).ready(function(){
 //add index column with all content.
 $(&quot;.filterable tr:has(td)&quot;).each(function(){
   var t = $(this).text().toLowerCase(); //all row text
   $(&quot;&lt;td class='indexColumn'&gt;&lt;/td&gt;&quot;)
    .hide().text(t).appendTo(this);
 });//each tr
 $(&quot;#FilterTextBox&quot;).keyup(function(){
   var s = $(this).val().toLowerCase().split(&quot; &quot;);
   //show all rows.
   $(&quot;.filterable tr:hidden&quot;).show();
   $.each(s, function(){
       $(&quot;.filterable tr:visible .indexColumn:not(:contains('&quot;
          + this + &quot;'))&quot;).parent().hide();
   });//each
 });//key up.
});//document.ready
</pre>
<h3>Explanation:</h3>
<ol>
<li><strong>Create Index Column</strong> &#8211; lines 2-7 &#8211; The <a href="http://docs.jquery.com/Selectors/contains">jQuery &#8220;:contains()&#8221; selector</a> is case sensitive, so at the first step I create another column on the table, than contains the whole row&#8217;s text on lowered case. On line 3 you may have noticed I&#8217;m filtering only rows that has &lt;td&gt;, to avoid hiding the header column (presumably, the header only has &lt;th&gt;). Later, I could make searches in this column alone. This works as long as the text on the table doesn&#8217;t change.</li>
<li><strong>Bind the Key-Up Event</strong> &#8211; lines 8-16.</li>
<li><strong>Make an array with all filter keywords</strong> &#8211; line 9 &#8211; Get all word from the text box and put them in an array. Again, I&#8217;m using toLowerCase() because &#8220;:contains&#8221; is case sensitive.</li>
<li><strong>Hide rows</strong> &#8211; lines 12-15 &#8211; I&#8217;m using <a href="http://docs.jquery.com/Utilities/jQuery.each">jQurey&#8217;s each function</a> to go through the array, and hiding all rows that don&#8217;t contain the current keyword (Assuming AND between all words).</li>
</ol>
<p>That&#8217;s it. Now rows on our table can be filtered.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/kobikobi.wordpress.com/56/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/kobikobi.wordpress.com/56/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kobikobi.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kobikobi.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kobikobi.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kobikobi.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kobikobi.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kobikobi.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kobikobi.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kobikobi.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kobikobi.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kobikobi.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=56&subd=kobikobi&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://kobikobi.wordpress.com/2008/09/15/using-jquery-to-filter-table-rows/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd75cd399cd893182d6e3d06d738d6d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kobi</media:title>
		</media:content>
	</item>
		<item>
		<title>Converting DataSets to Strongly-Typed DataSets</title>
		<link>http://kobikobi.wordpress.com/2008/09/11/converting-datasets-to-strongly-typed-datasets/</link>
		<comments>http://kobikobi.wordpress.com/2008/09/11/converting-datasets-to-strongly-typed-datasets/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 09:05:32 +0000</pubDate>
		<dc:creator>Kobi</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dataset]]></category>
		<category><![CDATA[datatable]]></category>
		<category><![CDATA[generics]]></category>

		<guid isPermaLink="false">http://kobikobi.wordpress.com/?p=40</guid>
		<description><![CDATA[One of the first things shown to me when I started working in my company was Microsoft&#8217;s Data Access Application Block. One thing that bothered me was that I constantly had to convert DataSets it returned to strongly typed DataSets used in our programs, which usually meant merging the returned data set with a newly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=40&subd=kobikobi&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of the first things shown to me when I started working in my company was Microsoft&#8217;s Data Access Application Block. One thing that bothered me was that I constantly had to convert DataSets it returned to strongly typed DataSets used in our programs, which usually meant merging the returned data set with a newly created DataTable. To relieve myself of those repeating tedious 6 lines of code, I made this little class that converts untyped DataSets and DataTables to a strongly typed DataTable.<br />
In a first attempt to solve this problem, I used reflation to create an instance of the typed DataTable, so I had to pass the method the type of the DataTable, and cast it back to itself.<br />
This is a more elegant solution, using generics:</p>
<pre class="brush: csharp;">
/// &lt;summary&gt;
/// Helper methods and functions.
/// &lt;/summary&gt;
/// &lt;typeparam name=&quot;T&quot;&gt;A strongly type DataTable.
/// A DataTable of type T will be returned from the DataSet.
/// &lt;/typeparam&gt;
public static class DataSetAdapter&lt;T&gt;
                          where T : DataTable, new()
{
    /// &lt;summary&gt;
    /// Convert the first DataTable from a DataSet to a
    /// strongly-typed data table.
    /// &lt;/summary&gt;
    public static T convert(DataSet dataSet)
    {
        if (dataSet == null)
            return null;
        if (dataSet.Tables.Count == 0)
            return null;
        DataTable dataTable = dataSet.Tables[0];
        return convert(dataTable);
    }
    /// &lt;summary&gt;
    /// Convert an ordinary DataTable to a strongly-typed
    /// data table.
    /// &lt;/summary&gt;
    public static T convert(DataTable dataTable)
    {
        if (dataTable == null)
            return null;
        T stronglyTyped = new T();
        // add data from the regular DataTable to the
        // strongly typed DataTable.
        stronglyTyped.Merge(dataTable);
        return stronglyTyped;
    }
}
</pre>
<p>The use of the class if pretty straightforward, just pass the DataSet and the Type:
<pre class="brush: csharp;">
DataSet employeesDataSet = OracleHelper.ExecuteDataset(
 connectionString, storedProcedure, parameters);
EmployeesDataTable employees =
 DataSetAdapter&lt;EmployeesDataTable&gt;.convert(employeesDataSet);
</pre>
<p>Links:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/cc511547.aspx">Data Application Block documentation by Microsoft</a></li>
<li><a href="http://www.koders.com/csharp/fid4700D828411F8CC19782B1E75CB44D6C719632A0.aspx?s=mdef%3Adataset">Data Application Block source code</a></li>
</ul>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/kobikobi.wordpress.com/40/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/kobikobi.wordpress.com/40/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kobikobi.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kobikobi.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kobikobi.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kobikobi.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kobikobi.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kobikobi.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kobikobi.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kobikobi.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kobikobi.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kobikobi.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=40&subd=kobikobi&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://kobikobi.wordpress.com/2008/09/11/converting-datasets-to-strongly-typed-datasets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd75cd399cd893182d6e3d06d738d6d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kobi</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Chrome, First Impression</title>
		<link>http://kobikobi.wordpress.com/2008/09/04/google-chrome-first-impression/</link>
		<comments>http://kobikobi.wordpress.com/2008/09/04/google-chrome-first-impression/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 15:05:16 +0000</pubDate>
		<dc:creator>Kobi</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[Review]]></category>

		<guid isPermaLink="false">http://kobikobi.wordpress.com/?p=29</guid>
		<description><![CDATA[[caption id="attachment_31" align="alignright" width="300" caption="Google Chrome Screenshot"]<a href="http://kobikobi.files.wordpress.com/2008/09/chrome.png"><img src="http://kobikobi.wordpress.com/files/2008/09/chrome.png?w=300" alt="Google Chrome Screenshot" width="300" height="224" class="size-medium wp-image-31" /></a>[/caption]
Like many of us, I've spent much time yesterday evaluating Google Chrome. Here are some of my thoughts about Chrome:

While many features are missing from Chrome, I should note the exceptional design and
attention to details. Chrome is so usable, you can easily miss its features.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=29&subd=kobikobi&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Like many of us, I&#8217;ve spent much time yesterday evaluating Google Chrome. Here are some of my thoughts about Chrome:</p>
<p>While many features are missing from Chrome, I should note the exceptional design and<br />
attention to details. Chrome is so usable, you can easily miss its features. For example, try to open many tabs, and than start closing them by middle clicking, or the close button. While you close tabs, Chrome does not resize them until you move away, so after one tab is closed, the next appears on the same spot. And the link destination status-bar, moving out of the window gracefully when the mouse is near it.<br />
<div id="attachment_31" class="wp-caption alignright" style="width: 310px"><a href="http://kobikobi.files.wordpress.com/2008/09/chrome.png"><img src="http://kobikobi.files.wordpress.com/2008/09/chrome.png?w=300&#038;h=224" alt="Google Chrome Screenshot" width="300" height="224" class="size-medium wp-image-31" /></a><p class="wp-caption-text">Google Chrome Screenshot</p></div><br />
And &#8220;find in page&#8221; highlights the word automatically, and also highlights the scrollbar to where these results are. Nice one. These are small details, of course, but I think they show how well the interface is though out.<br />
I was fairly impressed by the so-called omnibar, Chrome&#8217;s Url bar. I didn&#8217;t find it a lot better that Firefox&#8217;s bar though. Also, a lot has been said of Chrome&#8217;s speed and memory footprint. I&#8217;ll admit, I wish Firefox load pages this fast&#8230;</p>
<h3>Some obvious things I miss on Chrome:</h3>
<ol>
<li><strong>List of open tabs</strong> &#8211; I could not find a list of all open tabs. Ctrl+Esc shows a list of all processes, but I cannot select tabs from there.</li>
<li><strong>Multiple Tabs</strong> &#8211; I can move one tab to a new window, but what about a group of tabs, or uniting windows? I&#8217;d expect selecting tabs with Shift or Ctrl, but no.</li>
<li><strong>Non-standard Interface</strong> &#8211; Google redraws the interface, and the obviously didn&#8217;t want to include a status bar at the bottom of their window. One thing they forgot: that little gripper at the corner that resizes the window. Not visible even with both scollbars visible.</li>
<li><strong>Popup blocker</strong> &#8211; The blocked windows looks like a title of a window on the bottom of the current tab, hiding the bottom of the page and the horizontal scrollbar. I think the Firefox \ Explorer way is more comfortable, although they can move the information bar to the bottom, if they like. Chrome&#8217;s way is distracting, almost like a popup. and gets in the way, like a popup.</li>
<li><strong>Default language</strong> &#8211; I&#8217;m Israeli, that&#8217;s true. But I use an English system. Chrome default language was Hebrew, without any warning. The setup was English, and the download site. Even after I changed the interface to English, I had to remove Israeli search engines and manually change the omnibar&#8217;s search to English.</li>
<li><strong>Plugins!</strong> &#8211; It&#8217;s a different web with <a href="https://addons.mozilla.org/en-US/firefox/addon/1865">adblock</a>. And I miss <a href="https://addons.mozilla.org/en-US/firefox/addon/1122">changing tabs with the mouse wheel</a>.</li>
<li><strong>Rss support</strong> &#8211; I click on an RSS file, and I see it&#8217;s content as if it was HTML. Ok, I don&#8217;t think a browser needs an RSS reader. I don&#8217;t even think browsers need bookmarks. But at least ask me what I want to do with it, or display XML nicely. Well, I&#8217;m sure this feature will come.</li>
</ol>
<h3>And lastly, some (two) links:</h3>
<p><a href="http://www.readwriteweb.com/archives/security_flaw_in_google_chrome.php">Chrome security hole</a><br />
<a href="http://googlesystem.blogspot.com/2008/09/google-chromes-about-pages.html">About pages</a> &#8211; comments have some bugs, with a sure way to crash Chrome. It&#8217;s ok. It&#8217;s new.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/kobikobi.wordpress.com/29/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/kobikobi.wordpress.com/29/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kobikobi.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kobikobi.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kobikobi.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kobikobi.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kobikobi.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kobikobi.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kobikobi.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kobikobi.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kobikobi.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kobikobi.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=29&subd=kobikobi&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://kobikobi.wordpress.com/2008/09/04/google-chrome-first-impression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd75cd399cd893182d6e3d06d738d6d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kobi</media:title>
		</media:content>

		<media:content url="http://kobikobi.files.wordpress.com/2008/09/chrome.png?w=300" medium="image">
			<media:title type="html">Google Chrome Screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Sharepoint&#8217;s File Type Icons</title>
		<link>http://kobikobi.wordpress.com/2008/08/25/using-sharepoints-file-type-icons/</link>
		<comments>http://kobikobi.wordpress.com/2008/08/25/using-sharepoints-file-type-icons/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 12:45:49 +0000</pubDate>
		<dc:creator>Kobi</dc:creator>
				<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[web part]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://kobikobi.wordpress.com/?p=14</guid>
		<description><![CDATA[We have an old web part that displays documents from a list, and shows an icon next to file. After reading the list, the web part has a long &#8220;if-else&#8221; block that checks the files extension and displays the proper image. The images come from sharepoint template directory. I need to update this web part [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=14&subd=kobikobi&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>We have an old web part that displays documents from a list, and shows an icon next to file. After reading the list, the web part has a long &#8220;if-else&#8221; block that checks the files extension and displays the proper image. The images come from sharepoint template directory. I need to update this web part to display more file types icons. At first we though to create a list that maps images to extensions, but after little research I&#8217;ve decided to read sharepoint&#8217;s docicon.xml file.<br />
First, we need to find the file docicon.xml. The file usually sits under
<pre>C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\template\xml\docicon.xml</pre>
<p>The xml directory is not mapped on the IIS, but we can still find it using this little trick:</p>
<pre class="brush: csharp;">
string path = MapPathSecure(&quot;~/_layouts/&quot;);
path = Path.Combine(path, @&quot;..\xml\docicon.xml&quot;);
</pre>
<p>Now all that&#8217;s left is to read the xml and add the data to a collection:<br />
(This is actually the first time using XmlDataReader, but how wrong can I be?)<br />
First, we define two members, for all files and the default icon, and then go through the XML nodes:</p>
<pre class="brush: csharp;">
protected NameValueCollection fileTypeIcons;
protected string defaultIcon;

protected void readIconsXml()
{
    XmlReader reader = XmlReader.Create(path);
    reader.ReadToFollowing(&quot;ByExtension&quot;);
    //find the first child. This doesn't skip the first node.
    reader.ReadToFollowing(&quot;Mapping&quot;);
    while (reader.ReadToNextSibling(&quot;Mapping&quot;))
    {
        readOneNodeMapping(reader);
    }
    //find the default icon
    reader.ReadToFollowing(&quot;Default&quot;);
    reader.ReadToFollowing(&quot;Mapping&quot;);
    defaultIcon = reader.GetAttribute(&quot;Value&quot;);
}

protected void readOneNodeMapping(XmlReader reader)
{
    string tempKey = null;
    string tempValue = null;
    tempValue = reader.GetAttribute(&quot;Value&quot;);
    tempKey = reader.GetAttribute(&quot;Key&quot;);
    if ((tempKey != null) &amp;&amp; (tempValue != null))
        fileTypeIcons.Add(tempKey, tempValue);
}
</pre>
<p>And that&#8217;s it. We have all icons defined in the site ready in our project.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/kobikobi.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/kobikobi.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kobikobi.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kobikobi.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kobikobi.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kobikobi.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kobikobi.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kobikobi.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kobikobi.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kobikobi.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kobikobi.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kobikobi.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kobikobi.wordpress.com&blog=4238694&post=14&subd=kobikobi&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://kobikobi.wordpress.com/2008/08/25/using-sharepoints-file-type-icons/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd75cd399cd893182d6e3d06d738d6d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kobi</media:title>
		</media:content>
	</item>
	</channel>
</rss>