<?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/"
	>

<channel>
	<title>Sam Beauvois &#187; ASP.NET</title>
	<atom:link href="http://www.sambeauvois.be/blog/category/asp-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sambeauvois.be/blog</link>
	<description>general dev, .net and other stuff</description>
	<lastBuildDate>Tue, 27 Jul 2010 07:23:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Custom paging with Subsonic 3 and ObjectDataSource in ASP.NET</title>
		<link>http://www.sambeauvois.be/blog/2010/04/custom-paging-with-subsonic-3-and-objectdatasource-in-asp-net/</link>
		<comments>http://www.sambeauvois.be/blog/2010/04/custom-paging-with-subsonic-3-and-objectdatasource-in-asp-net/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 07:34:08 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[SubSonic]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=292</guid>
		<description><![CDATA[Here is how I created a paged items list in ASP.NET 3.5 using Subsonic for data access, and ASP.NET Controls for the display.
I use Subsonic 3.0.0.4 with ActiveRecord and ASP.NET 3.5 SP1 webforms.
For this example, we are creating a blog post list and that the DAL is created (the data class we use is &#8220;DAL.BlogPost&#8221;).
The [...]]]></description>
			<content:encoded><![CDATA[<p>Here is how I created a paged items list in ASP.NET 3.5 using Subsonic for data access, and ASP.NET Controls for the display.</p>
<p>I use Subsonic 3.0.0.4 with ActiveRecord and ASP.NET 3.5 SP1 webforms.</p>
<p>For this example, we are creating a blog post list and that the DAL is created (the data class we use is &#8220;DAL.BlogPost&#8221;).</p>
<p>The DAL.BlogPost object has three properties we need : CreatedOn, Subject and Body.</p>
<h4>First step : prepare your data manager class</h4>
<pre class="brush: csharp;">

namespace MyBlog.BLL
{
   public class PostManager
   {
     // ...
   }
}
</pre>
<p>(keep in mind the namespace and the class for the nexts steps)</p>
<p>In this class, two methods are required,</p>
<p>The first returns the total number of items</p>
<pre class="brush: csharp;">

public int GetPostCount()
{
  return DAL.BlogPost.All().Count(x =&gt; x.IsDeleted != true);
}
</pre>
<p>The second one returns the items contained in a defined range (start index and then nomber of elements), so this method needs to know where to start and how many items to get.</p>
<pre class="brush: csharp;">

public PagedList&lt;DAL.BlogPost&gt; GetLastestPosts(int startRowIndex, int maximumRows)
{
   if (startRowIndex != 0)
   {
     startRowIndex =(startRowIndex/maximumRows);
   }

    IOrderedQueryable&lt;DAL.BlogPost&gt; yourQuery = DAL.BlogPost.All().OrderByDescending(x =&gt; x.CreatedOn);
    return new PagedList&lt;DAL.BlogPost&gt;(yourQuery, startRowIndex, maximumRows);
}
</pre>
<p>One important part to remember when using Subsonic is</p>
<pre class="brush: csharp;">

if (startRowIndex != 0)
{
   startRowIndex = startRowIndex / maximumRows;
}
</pre>
<p>This conversion is necessary because subsonic and the ObjectDataSource doesn&#8217;t share the same opinion about the paging method.<br />
Subsonic says</p>
<blockquote><p>&#8220;I want the third page containing five elements&#8221;</p></blockquote>
<p>ObjectDataSource says</p>
<blockquote><p>&#8220;I want the five elements following the third element&#8221;</p></blockquote>
<p>So the conversion is mandatory if you want a correct paging.</p>
<h4>Second step : create the aspx page.</h4>
<p>Declare an ObjectDataSource:</p>
<pre class="brush: xml;">
&lt;asp:ObjectDataSource runat=&quot;server&quot; ID=&quot;postsDataSource&quot;
 TypeName=&quot;Example.BLL.PostManager&quot;
 SelectMethod=&quot;GetLastestPosts&quot;
 EnablePaging=&quot;true&quot;
 SelectCountMethod=&quot;GetPostCount&quot; &gt;
 &lt;/asp:ObjectDataSource&gt;
</pre>
<p>Note the TypeName attribute : the value is the namespace + the class name of our datamanager class.<br />
We set the EnablePaging attribute to true and we specify the SelectCountMethod and the SelectMethod.</p>
<p>We don&#8217;t need any parameters for the paging, by default the MaximumRowsParameterName and StartRowIndexParameterName are set to &#8220;maximumRows&#8221; and &#8220;startRowIndex&#8221;.<br />
If we want other parameters names in our datamanager class, we can define them in the ObjectDataSource with these two parameters.</p>
<p>Add an asp ListView element</p>
<pre class="brush: xml;">
&lt;asp:ListView runat=&quot;server&quot; ID=&quot;postsListview&quot;
     DataSourceID=&quot;postsDataSource&quot;&gt;
 &lt;LayoutTemplate&gt;
    &lt;asp:PlaceHolder ID=&quot;itemPlaceHolder&quot;
         runat=&quot;server&quot; /&gt;
 &lt;/LayoutTemplate&gt;
 &lt;ItemTemplate&gt;
    &lt;h2&gt;&lt;%# Eval(&quot;CreatedOn&quot;,&quot;{0:d}&quot;)%&gt; :
     &lt;%# Eval(&quot;Subject&quot;) %&gt;&lt;/h2&gt;
    &lt;br /&gt;
    &lt;p&gt;
     &lt;%# Eval(&quot;Body&quot;) %&gt;
    &lt;/p&gt;
    &lt;hr /&gt;
 &lt;/ItemTemplate&gt;
&lt;/asp:ListView&gt;
</pre>
<p>Set the DataSourceID attribute to the ObjectDataSource ID parameter.</p>
<p>Define a LayoutTemplate and an ItemTemplate with the elements we want to display.</p>
<p>Then add an asp datapager control in the LayoutTemplate</p>
<pre class="brush: xml;">

&lt;LayoutTemplate&gt;

  &lt;asp:DataPager ID=&quot;postsDataPager&quot; runat=&quot;server&quot;
       PageSize=&quot;3&quot;&gt;
    &lt;Fields&gt;
      &lt;asp:NextPreviousPagerField ButtonType=&quot;Link&quot;
           FirstPageText=&quot;&lt;&lt;&quot; PreviousPageText=&quot;&lt;&quot;
           ShowNextPageButton=&quot;false&quot;
           ShowFirstPageButton=&quot;true&quot; /&gt;
      &lt;asp:NumericPagerField PreviousPageText=&quot;...&quot;
           NextPageText=&quot;...&quot; ButtonCount=&quot;10&quot; /&gt;
      &lt;asp:NextPreviousPagerField ButtonType=&quot;Link&quot;
           LastPageText=&quot;&gt;&gt;&quot; NextPageText=&quot;&gt;&quot;
           ShowPreviousPageButton=&quot;false&quot;
           ShowLastPageButton=&quot;true&quot; /&gt;
     &lt;/Fields&gt;
   &lt;/asp:DataPager&gt;

   &lt;asp:PlaceHolder ID=&quot;itemPlaceHolder&quot; runat=&quot;server&quot; /&gt;
 &lt;/LayoutTemplate&gt;
</pre>
<p>Here is the result :<br />
<a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/blogposts.png" target="_blank"><img class="aligncenter size-medium wp-image-307" title="blogposts" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/blogposts-300x178.png" alt="blogposts" width="300" height="178" /></a></p>
<h4>Remark about the data access method</h4>
<p>It&#8217;s possible to avoid the start index value conversion !</p>
<p>Check the PagedList first constructor code (<a href="http://github.com/subsonic/SubSonic-3.0/blob/master/SubSonic.Core/Schema/PagedList.cs" target="_blank" onclick="pageTracker._trackPageview('/outgoing/github.com/subsonic/SubSonic-3.0/blob/master/SubSonic.Core/Schema/PagedList.cs?referer=');">code is available on the subsonic git repository</a>)</p>
<pre class="brush: csharp;">

public PagedList(IQueryable&lt;T&gt; source, int index, int pageSize)
{
   int total = source.Count();
   TotalCount = total;
   TotalPages = total / pageSize;

   if(total % pageSize &gt; 0)
     TotalPages++;

   PageSize = pageSize;
   PageIndex = index;
   AddRange(source.Skip(index * pageSize).Take(pageSize).ToList());
}
</pre>
<p>As you can see, Subsonic use the Skip and the Take methods from Linq</p>
<p>So, you can modify the GetLastestPosts method to return a<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;"> strongly <em> </em></span></span> typed List in place of the PagedList:</p>
<pre class="brush: csharp;">

public List&lt;DAL.BlogPost&gt; GetLastestPosts(int startRowIndex, int maximumRows)
{
   return DAL.BlogPost.All().
          Skip(startRowIndex).
          Take(maximumRows).
          OrderByDescending(x =&gt; x.CreatedOn).
          ToList&lt;DAL.BlogPost&gt;();
}
</pre>
<p>With this method, no more conversion needed</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/04/custom-paging-with-subsonic-3-and-objectdatasource-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use ASP.NET Validators with the SharePoint:DateTimeControl</title>
		<link>http://www.sambeauvois.be/blog/2010/03/use-asp-net-validators-with-the-sharepointdatetimecontrol/</link>
		<comments>http://www.sambeauvois.be/blog/2010/03/use-asp-net-validators-with-the-sharepointdatetimecontrol/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 09:54:21 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sharepoint]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=222</guid>
		<description><![CDATA[If you want to use asp.net validation system with the SharePoint’s DateTimeControl, the first thing you need to know is that this control is “just” a wrapper around simple ASP.NET controls (textbox, dropdownlist).
If you want to set the ControlToValidate property of an ASP.NET validator to the DateTimeControl’s ID, it will throw an error!
As you can [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to use asp.net validation system with the SharePoint’s DateTimeControl, the first thing you need to know is that this control is “just” a wrapper around simple ASP.NET controls (textbox, dropdownlist).</p>
<p>If you want to set the ControlToValidate property of an ASP.NET validator to the DateTimeControl’s ID, it will throw an error!<br />
As you can guess, you have to target the controls inside the DateTimeControl.</p>
<p>Since the DateTimeControl set the name of the controls programmatically, you can retrieve the id of the control:</p>
<ul>
<li>Textbox date: DateTimeControl.ID +”Date”</li>
<li>Dropdownlist hours: DateTimeControl.ID +”DateHours”</li>
<li>Dropdownlist minutes: DateTimeControl.ID +”DateMinutes”</li>
</ul>
<h3>Example:</h3>
<p>If you use the SharePoint:DateTimeControl with the TimeOnly property set to “true”</p>
<pre class="brush: xml;">

&lt;SharePoint:DateTimeControl runat=&quot;server&quot; ID=&quot;TheTime&quot; TimeOnly=&quot;true&quot;/&gt;
</pre>
<p>You’ll have two dropdownlists, one for the hours and one for the minutes<br />
The DateTimeControl set the name:</p>
<p>Dropdownlist hours: DateTimeControl.ID +”DateHours”</p>
<p>Html will be:</p>
<pre class="brush: xml;">
&lt;select name=&quot;ctl00$PlaceHolderMain$ctl07$ctl02$TheTime$TheTimeDateHours&quot; id=&quot;ctl00_PlaceHolderMain_ctl07_ctl02_TheTime_TheTimeDateHours&quot; dir=&quot;ltr&quot;&gt;
 &lt;option value=&quot;00:&quot;&gt;00:&lt;/option&gt;
 &lt;option value=&quot;01:&quot;&gt;01:&lt;/option&gt;
 &lt;option value=&quot;02:&quot;&gt;02:&lt;/option&gt;
 &lt;option value=&quot;03:&quot;&gt;03:&lt;/option&gt;
 &lt;option value=&quot;04:&quot;&gt;04:&lt;/option&gt;
 &lt;option value=&quot;05:&quot;&gt;05:&lt;/option&gt;
 &lt;option value=&quot;06:&quot;&gt;06:&lt;/option&gt;
 &lt;option value=&quot;07:&quot;&gt;07:&lt;/option&gt;
 &lt;option value=&quot;08:&quot;&gt;08:&lt;/option&gt;
 &lt;option value=&quot;09:&quot;&gt;09:&lt;/option&gt;
 &lt;option value=&quot;10:&quot;&gt;10:&lt;/option&gt;
 &lt;option value=&quot;11:&quot;&gt;11:&lt;/option&gt;
 &lt;option value=&quot;12:&quot;&gt;12:&lt;/option&gt;
 &lt;option value=&quot;13:&quot;&gt;13:&lt;/option&gt;
 &lt;option value=&quot;14:&quot;&gt;14:&lt;/option&gt;
 &lt;option value=&quot;15:&quot;&gt;15:&lt;/option&gt;
 &lt;option value=&quot;16:&quot;&gt;16:&lt;/option&gt;
 &lt;option value=&quot;17:&quot;&gt;17:&lt;/option&gt;
 &lt;option value=&quot;18:&quot;&gt;18:&lt;/option&gt;
 &lt;option value=&quot;19:&quot;&gt;19:&lt;/option&gt;
 &lt;option value=&quot;20:&quot;&gt;20:&lt;/option&gt;
 &lt;option value=&quot;21:&quot;&gt;21:&lt;/option&gt;
 &lt;option value=&quot;22:&quot;&gt;22:&lt;/option&gt;
 &lt;option value=&quot;23:&quot;&gt;23:&lt;/option&gt;
&lt;/select&gt;
</pre>
<p>Dropdownlist minutes: DateTimeControl.ID +”DateMinutes”<br />
Html will be:</p>
<pre class="brush: xml;">
&lt;select name=&quot;ctl00$PlaceHolderMain$ctl07$ctl02$TheTime$TheTimeDateMinutes&quot; id=&quot;ctl00_PlaceHolderMain_ctl07_ctl02_TheTime_TheTimeDateMinutes&quot; dir=&quot;ltr&quot;&gt;
 &lt;option value=&quot;00&quot;&gt;00&lt;/option&gt;
 &lt;option value=&quot;05&quot;&gt;05&lt;/option&gt;
 &lt;option value=&quot;10&quot;&gt;10&lt;/option&gt;
 &lt;option value=&quot;15&quot;&gt;15&lt;/option&gt;
 &lt;option value=&quot;20&quot;&gt;20&lt;/option&gt;
 &lt;option value=&quot;25&quot;&gt;25&lt;/option&gt;
 &lt;option value=&quot;30&quot;&gt;30&lt;/option&gt;
 &lt;option value=&quot;35&quot;&gt;35&lt;/option&gt;
 &lt;option value=&quot;40&quot;&gt;40&lt;/option&gt;
 &lt;option value=&quot;45&quot;&gt;45&lt;/option&gt;
 &lt;option value=&quot;50&quot;&gt;50&lt;/option&gt;
 &lt;option value=&quot;55&quot;&gt;55&lt;/option&gt;
&lt;/select&gt;
</pre>
<p><strong>So you can retrieve the ASP.NET controls by using :</strong></p>
<ul>
<li>For the date: TheTime$TheTimeDate</li>
<li>For the hours: TheTime$TheTimeDateHours</li>
<li>For the minutes: TheTime$TheTimeDateMinutes</li>
</ul>
<h3>Real case example:</h3>
<p>I have two DateTimeControl, one named TheStartTime and one other named TheEndTime,</p>
<p>I want to validate that the end time is not before the start time.</p>
<p>So I’ll use the ASP.NET comparevalidator validator to compare the hours:</p>
<pre class="brush: xml;">
&lt;asp:CompareValidator id=&quot;valDate&quot; runat=&quot;server&quot; ControlToValidate=&quot;TheEndTime$TheEndTimeDateHours&quot; ControlToCompare=&quot;TheStartTime$TheStartTimeDateHours&quot;
 Type=&quot;Integer&quot;
 Operator=&quot;GreaterThanEqual&quot;
 ErrorMessage=&quot;The end time must be greater than the start time&quot;&gt;
 &lt;/asp:CompareValidator &gt;
</pre>
<p>Now, if you want to validate both hours and minutes, one option is to add an “asp:CustomValidator” and check conditions server side :<br />
Markup:</p>
<pre class="brush: xml;">
&lt;asp:CustomValidator runat=&quot;server&quot; ID=&quot;EndTimeMustBeLaterThanStartTimeCustomValidator&quot;
EnableClientScript=&quot;false&quot; ErrorMessage=&quot;Start time must be before end time&quot;/&gt;
</pre>
<p>Before the action, validate:</p>
<pre class="brush: csharp;">
if (!IsEndTimeLaterThanStartTime())
{
 EndTimeMustBeLaterThanStartTimeCustomValidator.IsValid = false;
 return;
}
</pre>
<p>Validation method:</p>
<pre class="brush: csharp;">

private bool IsEndTimeLaterThanStartTime()
{
 // retrieve the DropDownList
 DropDownList startHours = TheStartTime.FindControl(&quot;TheStartTimeDateHours&quot;) as DropDownList;
 DropDownList endHours = TheEndTime.FindControl(&quot;TheEndTimeDateHours&quot;) as DropDownList;

 // prevent from errors
 if (startHours == null ||
 endHours == null ||
 string.IsNullOrEmpty(startHours.SelectedValue) ||
 string.IsNullOrEmpty(endHours.SelectedValue))
 {
 return; // dont' do anything
 }

// the hour value is &quot;00:&quot;
 int startHour = Convert.ToInt32(startHours.SelectedValue.Replace(&quot;:&quot;,&quot;&quot;));
 int endHour = Convert.ToInt32(endHours.SelectedValue.Replace(&quot;:&quot;, &quot;&quot;));
 if (endHour &lt; startHour)
 {
 args.IsValid = false;
 }
 else
 {

 if (endHour == startHour)
 {
 // check the minutes
 DropDownList startMinutes = TheStartTime.FindControl(&quot;TheStartTimeDateMinutes&quot;) as DropDownList;
 DropDownList endMinutes = TheEndTime.FindControl(&quot;TheEndTimeDateMinutes&quot;) as DropDownList;
 // prevent from errors
 if (startMinutes == null ||
 endMinutes == null ||
 string.IsNullOrEmpty(startMinutes.SelectedValue) ||
 string.IsNullOrEmpty(endMinutes.SelectedValue))
 {
 return; // dont' do anything
 }

 int startMinute = Convert.ToInt32(startMinutes.SelectedValue);
 int endMinute = Convert.ToInt32(endMinutes.SelectedValue);

 if (endHour &lt;= startMinute)
 args.IsValid = false;

 }
 }

 args.IsValid = true;

 }
</pre>
<p>You can also validate the Date himself if you choose to display it,<br />
you can make a client side validation if you know javascript,<br />
you can do everything like in “classic” ASP.NET.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/03/use-asp-net-validators-with-the-sharepointdatetimecontrol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Mixer</title>
		<link>http://www.sambeauvois.be/blog/2010/02/css-mixer/</link>
		<comments>http://www.sambeauvois.be/blog/2010/02/css-mixer/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 22:41:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=207</guid>
		<description><![CDATA[ Css mixer is a tool I&#8217;ve developped in C# winforms, .NET framework 3.5
You can use it to improve you ASP.NET Themes or your CSS files for all your web projects.
If you have many css files linked to a page, you can group them in a single file with CSS Mixer.
You can also minify CSS files [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cssmixer.codeplex.com/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/cssmixer.codeplex.com/?referer=');"><img class="alignleft size-full wp-image-206" title="CSSmixer128" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/CSSmixer128.png" alt="CSSmixer128" width="128" height="128" /></a> Css mixer is a tool I&#8217;ve developped in C# winforms, .NET framework 3.5</p>
<p>You can use it to improve you ASP.NET Themes or your CSS files for all your web projects.</p>
<p>If you have many css files linked to a page, you can group them in a single file with CSS Mixer.</p>
<p>You can also minify CSS files to save the bandwith.</p>
<p> </p>
<p>To use it, open a folder containing CSS files,</p>
<p style="text-align: center;"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/cssmixer_screenshot.png" target="_blank"><img class="aligncenter size-full wp-image-208" title="cssmixer_screenshot" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/cssmixer_screenshot.png" alt="cssmixer_screenshot" width="480" /></a></p>
<p>choose an action (simple combine, or combine and minify) then click Save as &#8230;</p>
<p style="text-align: center;"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/cssmixer_screenshot2.png" target="_blank"><img class="aligncenter size-full wp-image-209" title="cssmixer_screenshot2" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/cssmixer_screenshot2.png" alt="cssmixer_screenshot2" width="480" /></a></p>
<p>Download the last version of <a href="http://cssmixer.codeplex.com/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/cssmixer.codeplex.com/?referer=');">CSS Mixer on codeplex</a>.</p>
<p>I hope you&#8217;ll find it usefull. please give me feedback on it</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/02/css-mixer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to build a &#8220;visible on hover&#8221; action menu with jQuery ?</title>
		<link>http://www.sambeauvois.be/blog/2010/02/how-to-build-a-visible-on-hover-action-menu-with-jquery/</link>
		<comments>http://www.sambeauvois.be/blog/2010/02/how-to-build-a-visible-on-hover-action-menu-with-jquery/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 16:43:35 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=178</guid>
		<description><![CDATA[Here is a quick way to use jQuery library to create a &#8220;visible on hover&#8221; action menu.
I&#8217;ll explain step by step how to do that.
1.) Create an html page with actions in a container

&#60;html&#62;
 &#60;head&#62;
 &#60;title&#62;Sam Beauvois &#124; jQuery usage demo 1&#60;/title&#62;
 &#60;/head&#62;
 &#60;body&#62;
 &#60;h2&#62;Visible on hover with jQuery demo.&#60;h2&#62;
 &#60;h3&#62;Please put you mouse hover [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick way to use jQuery library to create a &#8220;visible on hover&#8221; action menu.</p>
<p>I&#8217;ll explain step by step how to do that.</p>
<p>1.) Create an html page with actions in a container</p>
<pre class="brush: xml;">
&lt;html&gt;
 &lt;head&gt;
 &lt;title&gt;Sam Beauvois | jQuery usage demo 1&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
 &lt;h2&gt;Visible on hover with jQuery demo.&lt;h2&gt;
 &lt;h3&gt;Please put you mouse hover the following texts&lt;/h3&gt;
 &lt;div&gt;
 Demo 1
 &lt;div&gt;
 &lt;a href=&quot;#&quot;&gt;action 1&lt;/a&gt; | &lt;a href=&quot;#&quot;&gt;action 2&lt;/a&gt; | &lt;a href=&quot;#&quot;&gt;action 3&lt;/a&gt;
 &lt;/div&gt;
 &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Result is</p>
<div id="attachment_182" class="wp-caption aligncenter" style="width: 396px"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/jquery.visible.on_.hover_.demo1_.png"><img class="size-full wp-image-182" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/jquery.visible.on_.hover_.demo1_.png" alt="simple page" width="386" height="276" /></a><p class="wp-caption-text">simple page</p></div>
<p>2.) Link the jquery library (here from google code, but you can download the library at <a href="http://www.jquery.com" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.jquery.com?referer=');">jquery.com</a>) and add a css class to the container div and one other to the action div</p>
<pre class="brush: xml;">

&lt;head&gt;
 &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot; &gt;&lt;/script&gt;
&lt;/head&gt;
</pre>
<pre class="brush: xml;">
&lt;body&gt;
&lt;div&gt;
 Demo 1
 &lt;div&gt;
 &lt;a href=&quot;#&quot;&gt;action 1&lt;/a&gt; | &lt;a href=&quot;#&quot;&gt;action 2&lt;/a&gt; | &lt;a href=&quot;#&quot;&gt;action 3&lt;/a&gt;
 &lt;/div&gt;
 &lt;/div&gt;
&lt;/body&gt;
</pre>
<p>3.) Add a function :</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
 $(document).ready(function()
 {
    ShowActionOnOver();
    $(&quot;.hidden_action&quot;,this).hide(); // hide all
 });

 function ShowActionOnOver()
 {
   $(&quot;.hidden_action_container&quot;).hover(
       function()
       {
          $(&quot;.hidden_action&quot;,this).show();
       },
       function()
       {
           $(&quot;.hidden_action&quot;,this).hide();
        }
    );
 }

 &lt;/script&gt;
</pre>
<p>Now it&#8217;s functionnal, hover the zone to check :</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/jquery.visible.on_.hover_.demo2_.png"><img class="aligncenter size-full wp-image-183" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/jquery.visible.on_.hover_.demo2_.png" alt="jquery.visible.on.hover.demo2" width="385" height="242" /></a></p>
<p>4.) Now, add some css to make it nicer :</p>
<pre class="brush: css;">
.hidden_action_container
{
 padding : 15px 15px 15px 15px;
 background-color: #DDDDDD;
 border-style:solid;
 border-color:#EEEEEE;
 height:50px;
}

.hidden_action a
{
 color:#999999;
 font-size: 20px;
 font-weight:bolder;
}
</pre>
<pre class="brush: xml;">
&lt;head&gt;
 &lt;link href=&quot;demo.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot; /&gt;
&lt;/head&gt;
</pre>
<p>And the final result looks like</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/jquery.visible.on_.hover_.demo3_.png"><img class="aligncenter size-full wp-image-184" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/jquery.visible.on_.hover_.demo3_.png" alt="jquery.visible.on.hover.demo3" width="386" height="463" /></a></p>
<h3>You can<a href="http://www.sambeauvois.be/Demos/jQuery/VisibleOnHover/demo.html" target="_blank"> see the online demo here.</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/02/how-to-build-a-visible-on-hover-action-menu-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t repeat your common CSS between your different themes</title>
		<link>http://www.sambeauvois.be/blog/2010/01/dont-repeat-your-common-css-between-your-different-themes/</link>
		<comments>http://www.sambeauvois.be/blog/2010/01/dont-repeat-your-common-css-between-your-different-themes/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 18:02:53 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=150</guid>
		<description><![CDATA[To fully understand this article, you need an Asp.Net Themes system knowledge
The case :
You have an application with a CSS layout, and a few themes.
There is just a little change between the different themes, by example you change only the color scheme.
A solution to do that is to repeat all CSS files in all your [...]]]></description>
			<content:encoded><![CDATA[<p>To fully understand this article, you need an Asp.Net Themes system knowledge</p>
<h3>The case :</h3>
<p>You have an application with a CSS layout, and a few themes.<br />
There is just a little change between the different themes, by example you change only the color scheme.</p>
<p>A solution to do that is to repeat all CSS files in all your themes, and change the color part.<br />
The problem with that solution is that if you change one common style in one of your themes, you’ll have to repeat the change in all themes. This is a bad idea, it leads to chaos !</p>
<h3>Then how can you do to avoid the code repetition ?</h3>
<h4>My solution:</h4>
<p>1.) Create a Common Theme.</p>
<p>In the Common theme, you define CCS files with a default color scheme (just in case)</p>
<pre class="brush: css;">
.testclass
{
border:solid 1px #DDDDDD;
background-color:#DDDDAA;
font-size:xx-large;
}
</pre>
<p>2.) Create an other Theme (let say “Green”)</p>
<p>In the Green theme, you define CCS files with only the color information</p>
<pre class="brush: css;">

.testclass
{
background-color:#00FF00;
}
</pre>
<p>2b.) Create an other Theme (let say “Blue”)</p>
<p>In the Green theme, you define CCS files with only the color information</p>
<pre class="brush: css;">

.testclass
{
background-color:#0000FF;
}
</pre>
<p>Your Theme structure has to look like this :</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image.png"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image_thumb.png" border="0" alt="image" width="190" height="134" /></a></p>
<p>3.) Create a default page (Default.aspx)</p>
<p>And set the class of a div to “testclass” (define above)</p>
<pre class="brush: xml;">
&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;Default.aspx.cs&quot; Inherits=&quot;ThemTests._Default&quot;
%&gt;

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head runat=&quot;server&quot;&gt;
 &lt;title&gt;Test with themes&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
 &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;
 &lt;div&gt;
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ut tellus eget turpis semper adipiscing sit amet id odio. Nunc vitae imperdiet tellus. Aenean quis orci metus, vitae placerat leo. Pellentesque luctus, lectus sit amet lacinia tincidunt, mi nibh sagittis nisl, vitae mollis eros nisi sit amet sem. Nunc dictum massa turpis. Etiam nisi mauris, consectetur et tempus id, pharetra in turpis. Nullam pretium ultricies nulla nec gravida. Sed porttitor metus nisl, ac condimentum nunc. Integer id feugiat orci. Maecenas ut lacinia purus. Mauris egestas mattis accumsan. Nunc in justo massa, quis egestas orci. Ut tincidunt, ligula sit amet tempor pharetra, magna mauris gravida mi, sed semper magna justo at velit. Donec vulputate fringilla lacus non sollicitudin. Morbi nulla nibh, pellentesque sed bibendum cursus, malesuada ut nisi.
 &lt;/div&gt;
 &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>4.) Edit the Web.Config file</p>
<p>Go to the “Pages” section, set the styleSheetTheme attribute to “Common” and the theme attribute to “Green”</p>
<pre class="brush: xml;">

&lt;pages styleSheetTheme=&quot;Common&quot; theme=&quot;Green&quot;&gt;
</pre>
<p>Now launch your web application, the result has to be like this :</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image1.png"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image_thumb1.png" border="0" alt="image" width="604" height="484" /></a></p>
<p>See in firebug :</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image2.png"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image_thumb2.png" border="0" alt="image" width="644" height="252" /></a></p>
<h3>Explanation :</h3>
<p>This works because of the styleSheetTheme and theme attributes.</p>
<p>In fact, ASP.NET applies the styleSheetTheme defined theme first, then applies the page defined styles and at least applies the theme defined theme.</p>
<p>With this technique you can get rid of a few headaches.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/01/dont-repeat-your-common-css-between-your-different-themes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to change the style elements of a listview? (the simple way)</title>
		<link>http://www.sambeauvois.be/blog/2010/01/how-to-change-the-style-elements-of-a-listview-the-simple-way/</link>
		<comments>http://www.sambeauvois.be/blog/2010/01/how-to-change-the-style-elements-of-a-listview-the-simple-way/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 13:14:40 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=141</guid>
		<description><![CDATA[With the ast.net listview control, you can set an AlternatingItemTemplate in order to change the display or what you want.
If you just want to change the backcolor or things like that, you can spare some time by using only the ItemTemplate and applying a diffenrent style depending of the index (use of the Container.DataItemIndex property).
example [...]]]></description>
			<content:encoded><![CDATA[<p>With the ast.net listview control, you can set an <em>AlternatingItemTemplate </em>in order to change the display or what you want.</p>
<p>If you just want to change the backcolor or things like that, you can spare some time by using only the <em>ItemTemplate </em>and applying a diffenrent style depending of the index (use of the <strong>Container.DataItemIndex</strong> property).</p>
<p><em>example</em> : let’s say that your listview generate a &lt;table&gt; and each <em>ItemTemplate</em> generate a row of this table, just do :</p>
<pre class="brush: xml;">
&lt;ItemTemplate&gt;
  &lt;tr class='&lt;%# Container.DataItemIndex % 2 == 0 ? “normal” : “alternating” %&gt;'&gt;
    &lt;td&gt;blah blah&lt;/td&gt;
  &lt;/tr&gt;
&lt;/ItemTemplate&gt;
</pre>
<p><span><span style="background-color: #ffffff" title="c'est tout">that&#8217;s all you need !<br />
</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/01/how-to-change-the-style-elements-of-a-listview-the-simple-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use a ValidationSummary to display server errors?</title>
		<link>http://www.sambeauvois.be/blog/2010/01/asp-net-howto-use-a-validationsummary-to-display-server-errors/</link>
		<comments>http://www.sambeauvois.be/blog/2010/01/asp-net-howto-use-a-validationsummary-to-display-server-errors/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 07:15:17 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=133</guid>
		<description><![CDATA[Imagine you want to use your ValidationSummary to display server errors as client error, there is a simple way to do that.
First, declare your ValidationSummary, and a CustomValidator with Display property set to &#8220;None&#8221;


&#60;asp:CustomValidator ID=&#34;ServerErrorCustomValidator&#34;
Display=&#34;None&#34; runat=&#34;server&#34; ValidationGroup=&#34;MyValidationGroup&#34; /&#62;

&#60;asp:ValidationSummary ID=&#34;AdministrationTaskValidationSummary&#34; runat=&#34;server&#34; ValidationGroup=&#34;MyValidationGroup&#34;/&#62;

Next, in your application code, when an error occurs : set the CustomValidator&#8217;s ErrorMessage and [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine you want to use your ValidationSummary to display server errors as client error, there is a simple way to do that.</p>
<p>First, declare your <strong>ValidationSummary</strong>, and a <strong>CustomValidator </strong>with <strong>Display </strong>property set to <em><strong>&#8220;None&#8221;</strong></em></p>
<pre class="brush: xml;">

&lt;asp:CustomValidator ID=&quot;ServerErrorCustomValidator&quot;
Display=&quot;None&quot; runat=&quot;server&quot; ValidationGroup=&quot;MyValidationGroup&quot; /&gt;

&lt;asp:ValidationSummary ID=&quot;AdministrationTaskValidationSummary&quot; runat=&quot;server&quot; ValidationGroup=&quot;MyValidationGroup&quot;/&gt;
</pre>
<p>Next, in your application code, when an error occurs : set the CustomValidator&#8217;s <strong>ErrorMessage </strong>and <strong>IsValid </strong>properties :</p>
<pre class="brush: csharp;">

ServerErrorCustomValidator.ErrorMessage = &quot;Server error :  error description&quot;;
ServerErrorCustomValidator.IsValid = false;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/01/asp-net-howto-use-a-validationsummary-to-display-server-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
