<?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>xLevel.org.uk</title>
	<atom:link href="http://xlevel.org.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://xlevel.org.uk</link>
	<description></description>
	<lastBuildDate>Tue, 21 Feb 2012 21:38:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Issues with configuring approval workflows in EPiServer</title>
		<link>http://xlevel.org.uk/issues-with-configuring-approval-workflows-in-episerver/</link>
		<comments>http://xlevel.org.uk/issues-with-configuring-approval-workflows-in-episerver/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 21:38:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EPiServer]]></category>

		<guid isPermaLink="false">http://xlevel.org.uk/?p=100</guid>
		<description><![CDATA[Ever since the release of EPiServer CMS 5, workflow within EPiServer CMS has been based on Microsoft&#8217;s Workflow Foundation. Out of the box EpiServer comes with four pre-configured workflows: Sequential Approval Parallel Approval Request For Feedback Ready For Translation Issues with &#8230;<p class="read-more"><a href="http://xlevel.org.uk/issues-with-configuring-approval-workflows-in-episerver/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Ever since the release of EPiServer CMS 5, workflow within EPiServer CMS has been based on <a href="http://msdn.microsoft.com/en-us/netframework/aa663328" target="_blank">Microsoft&#8217;s Workflow Foundation</a>. Out of the box EpiServer comes with four pre-configured workflows:</p>
<ul>
<li>Sequential Approval</li>
<li>Parallel Approval</li>
<li>Request For Feedback</li>
<li>Ready For Translation</li>
</ul>
<h2>Issues with the approval workflows</h2>
<p>The sequential and parallel approval workflows are designed to regulate the publishing of pages within the website. However, there are a couple of features with the out of the box design that could cause issues if you want to use these approval workflows to automatically regulate the publishing of pages on your website.</p>
<h3><strong>1. These workflows required that any approvers have to have publish access to that page.</strong></h3>
<p>This means that approvers can bypass the workflow system and publish the page before it has gone through all it&#8217;s stages.</p>
<h3><strong>2. The workflows do not check if there is an existing workflow instance for that page before creating a new one.</strong></h3>
<p>If a page is set to <strong>&#8220;Not Approved&#8221;</strong> a task is created for the original editor which allows them to send the workflow back to the approvers. If an edit is done, this workflow can be associated with the new version of the page. The trouble comes if you have set the workflow to be created by one of the events involved with the editing process (either <strong>Save</strong> or <strong>Ready to Publish</strong>) then a new instance of the workflow will be created, leading to multiple instances of the workflow for a page.</p>
<h2>Getting workflows to work</h2>
<p>Getting the approval workflows to work in a more logical way is not easy because of the highly bound way that EPiServer built the workflow system.</p>
<h3>Step 1. New Approval Service</h3>
<p>To remove the requirement for an approver to have publish access, the <code><strong>HasReadAndPublishRights</strong></code> method of the <code><strong>EPiServer.WorkflowFoundation.Workflows.ApprovalService</strong></code> class needs to be modified. Although the method is public it is not virtual, and because of how it is accessed internally and externally, inheriting from it and marking the new method as <code><strong>new</strong></code> will not work. The only solution is to copy the source into a replacement class and edit the <code><strong>HasReadAndPublishRights</strong></code> method to remove the checks for <strong>Publish</strong> access.</p>
<p>EPiServer.Config will need to be updated replacing the <code><strong>&lt;externalService&gt;</strong></code> entry for the EPiServer <code><strong>ApprovalService</strong></code> with your new one.</p>
<h3>Step 2. Replacing the workflow dialogs</h3>
<p>Unfortunately this is only the start of the issues. There is a tight coupling between the <code><strong>ApprovalService</strong></code> class and the controls used to display the task forms. To get around this, a number of ascx files need to be copied from the <strong>CMS/edit</strong> folder into a folder in your web project:</p>
<ul>
<li>WorkflowApprovalStart.ascx</li>
<li>WorkflowApprovalEvent.ascx</li>
<li>WorkflowTaskControl.ascx</li>
<li>WorkflowHistoryList.ascx</li>
<li>WorkflowApprovalVersion.ascx</li>
</ul>
<p>To redirect calls from the original controls to the new ones we can use the EPiServer virtual path mapping provider.</p>
<p><code><strong>&lt;virtualPath customFileSummary="~/FileSummary.config"&gt;</strong></code><br />
<code><strong>    &lt;providers&gt;</strong></code><br />
<code><strong>    .... </strong></code><br />
<code><strong>    &lt;add showInFileManager="false" virtualName="WFMapping" virtualPath="~/episerver/CMS" </strong></code><br />
<code><strong>        bypassAccessCheck="false" name="WFMapping" </strong></code><br />
<code><strong>        type="EPiServer.Web.Hosting.VirtualPathMappedProvider,EPiServer"/&gt;</strong></code><br />
<code><strong>    &lt;/providers&gt; </strong></code><br />
<code><strong>    &lt;filters /&gt;</strong></code><br />
<code><strong>&lt;/virtualPath&gt;</strong></code><br />
<code><strong>&lt;virtualPathMappings&gt;</strong></code><br />
<code><strong>    &lt;add url="~/episerver/CMS/edit/WorkflowApprovalStart.ascx" </strong></code><br />
<code><strong>        mappedUrl="~/controls/workflow/WorkflowApprovalStart.ascx"/&gt;</strong></code><br />
<code><strong>    ....</strong></code><br />
<code><strong>&lt;/virtualPathMappings&gt;</strong></code></p>
<p>The source of <strong>WorkflowApprovalStart.ascx</strong> and <strong>WorkflowApprovalEvent.ascx</strong> both need copying into new class files and the controls edited to use them. This is so they can be pointed to use the new <code><strong>ApprovalService</strong></code> class.</p>
<p>The <strong>WorkflowTaskControl.ascx</strong> source code needs to be copied and the <code><strong>TryLoadControlFromAttribute</strong></code> method needs modifying. This method looks at an workflow activity and loads the control specified by it&#8217;s ActivityPlugIn attribute. Unfortunately this URL will point to the original controls not your new ones. Modifying this method to use the <strong>VirtualPathMappings</strong> configuration settings to look up the new control URL and use this to load the new control.</p>
<p>The <strong>WorkflowHistoryList.ascx</strong> and <strong>WorkflowApprovalVersion.ascx</strong> can be left as is as they are only there to make <strong>WorkflowTaskControl.ascx</strong> compile.</p>
<h2>Step 3. Only one workflow instance per page</h2>
<p>As described above there are a few scenarios that could lead to a page having multiple running workflow instances.</p>
<p>Both of the approval workflows use an <code><strong>IsValidParameter</strong></code> method to check if the workflow has the right parameter settings to be assigned to approvers or, if not, just closed. Modifying this to check if there is a running workflow instance, other than the current one, already exists and returning false if it does. This stops multiple running workflow instances existing for the same page.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://xlevel.org.uk/issues-with-configuring-approval-workflows-in-episerver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speeding up EPiServer dynamic properties</title>
		<link>http://xlevel.org.uk/speeding-up-episerver-dynamic-properties/</link>
		<comments>http://xlevel.org.uk/speeding-up-episerver-dynamic-properties/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 17:58:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EPiServer]]></category>

		<guid isPermaLink="false">http://xlevel.org.uk/?p=86</guid>
		<description><![CDATA[Dynamic properties are a very useful feature in EPiServer, however, they have always been know to be slow. Pre EPiServer CMS 6 R2 There is a fix detailed in Svante Seleborg&#8217;s post &#8220;Dynamic Properties performance revisited&#8220;. The speed problem is &#8230;<p class="read-more"><a href="http://xlevel.org.uk/speeding-up-episerver-dynamic-properties/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Dynamic properties are a very useful feature in EPiServer, however, they have always been know to be slow.</p>
<h2>Pre EPiServer CMS 6 R2</h2>
<p>There is a fix detailed in Svante Seleborg&#8217;s post &#8220;<a href="http://world.episerver.com/Blogs/Svante-Seleborg/Dates/2010/9/Dynamic-Properties-performance-revisited/" target="_blank">Dynamic Properties performance revisited</a>&#8220;.</p>
<p>The speed problem is partly because the temporary table created within the <strong>netDynamicProperties</strong> stored procedure does not having an index. The fix is to add an index to the temporary table. Adding this line to the stored procedure creates the index:</p>
<p><code><strong>create clustered index idx_tmpprop_fkParentID on #tmpprop ( fkParentID )</strong></code></p>
<h2>CMS6 R2 Onwards</h2>
<p>The performance issues with dynamic properties have been fixed in EPiServer CMS 6 R2</p>
<p>The full details of the fix are detailed in Magnus Stråle&#8217;s post &#8220;<a href="http://world.episerver.com/Blogs/Magnus-Strale/Dates/2010/10/Dynamic-property-performance-improvements/" target="_blank">Dynamic property performance improvements</a>&#8220;.</p>
<p>There is a useful side effect to this, the addition of theanew <strong>NullLanguageSelector</strong>. This can be used in a call to the GetPage method, to return a non language specific PageData. Using this is supposed to give a 5-10% speed improvement.</p>
]]></content:encoded>
			<wfw:commentRss>http://xlevel.org.uk/speeding-up-episerver-dynamic-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up a new EPiServer project on Windows 7 and IIS7.5</title>
		<link>http://xlevel.org.uk/setting-up-a-new-episerver-project-on-windows-7-and-iis7-5/</link>
		<comments>http://xlevel.org.uk/setting-up-a-new-episerver-project-on-windows-7-and-iis7-5/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 21:04:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EPiServer]]></category>

		<guid isPermaLink="false">http://xlevel.org.uk/?p=81</guid>
		<description><![CDATA[I don&#8217;t know about you, but I always prefer to have my development environment as close to what is on the live servers as possible. As such, I always prefer to develop using IIS and a locally pointed domain rather &#8230;<p class="read-more"><a href="http://xlevel.org.uk/setting-up-a-new-episerver-project-on-windows-7-and-iis7-5/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know about you, but I always prefer to have my development environment as close to what is on the live servers as possible. As such, I always prefer to develop using IIS and a locally pointed domain rather then either Cassini, Visual Studio&#8217;s inbuilt web server, or IIS Express, accessed via <strong>localhost</strong> and a port number.</p>
<p>Setting up an EPiServer development environment is one of those jobs that only gets done once in the lifetime of the project, and as such, I always find myself having to remind myself how to do it. Here are my steps to set up my favoured development environment.</p>
<p><strong>NOTE:</strong> These steps have only been tested using Windows 7, IIS 7.5 and EPiServer CMS 6 R2. I have not tried it on other platforms and with other versions of EPiServer.</p>
<h2>Create an EPiServer project</h2>
<p>The first step is to create a EPiServer project within Visual Studio. As long as you have installed <a href="http://world.episerver.com/Download/" target="_blank">EPiServer CMS and the SDK</a> you should have an EPiServer folder in your New Project dialog window.</p>
<p>All you need to do is put in the project name and press OK.</p>
<h2>Change the project to .Net 4</h2>
<p>You need to save and close the solution before doing this. Once you have re-opened the solution select the project properties.</p>
<p>On the <strong>Application</strong> tab change the <strong>Target Framework</strong> to .Net 4.</p>
<h2>Make changes to the Web.config</h2>
<p>There are a number of changes you will need to make to the <strong>web.config</strong> file. These are detailed in articles by  <a href="http://world.episerver.com/Articles/Items/EPiServer-CMS-60-now-supporting-ASPNET-40/" target="_blank">Allan Thræn</a> and <a href="http://www.david-tec.com/2011/05/Default-webconfig-files-for-EPiServer-CMS-6-R2-running-net-40/" target="_blank">David Knipe</a>. If you are a user of NuGet, there is a package called <a href="http://www.david-tec.com/2011/05/Nuget-package-to-convert-an-EPiServer-site-to-ASPnet-40/" target="_blank">EPiServerCMS6ToNetFour</a> available which will do the changes for you.</p>
<h2>Create the VPP folder</h2>
<p>A VPP folder is created as part of the project, but it is in the developers user profile folder and, as it uses the <strong>%USERPROFILE%</strong> variable, it will cause an error when the site is running within IIS.</p>
<p>To fix this, create a new VPP folder, with the required sub folders (Globals, Documents and PageFiles by default) and replace the <strong>%USERPROFILE%</strong> variable with the absolute file path to here.</p>
<h2>Create a blank EPiServer database</h2>
<p>The out of the box EPiServer project creates an <strong>EPiServerDB.mdf</strong> file in the <strong>App_Data</strong> folder. As other developers may need to access the database and because I prefer to have the development environment as close to live as possible I want the database to be hosted on a proper SQL Server database.</p>
<p>Using <strong>EPiServer Deployment Centre</strong> create a new, blank database on the appropriate SQL Server instance and then change the connection string in <strong>connectionStrings.config</strong> to point to it.</p>
<h2>Create a new domain, website and app pool</h2>
<p>Firstly create an entry in your hosts file for the domain you are going to be using to access the site. This needs to point to the local machine ip, i.e. 127.0.0.1.</p>
<p>Once this is done the<strong> episerver.config</strong> file needs editing to set the <strong>siteUrl</strong> attribute of <strong>siteSettings</strong> node needs to be set to the new domain name.</p>
<p>Next, open IIS Manager and create a new Website. Point the folder to your EPiServer projects website development folder and bind it to the domain name you added to your hosts file.</p>
<p>Lastly, change the app pool used by your new website to be <strong>.Net 4</strong> and to use <strong>Intergrated Pipeline</strong> mode.</p>
<h2>Lastly, get a EPiServer licence key</h2>
<p>As the site is not being accessed by <strong>localhost</strong>, but by a domain name you will need a EPiServer licence to work with this. Demo and partner developer licences are available from the <a href="https://license.episerver.com/" target="_blank">EPiServer Licence Center</a> website.</p>
<h2>Developing in Visual Studio as Administrator</h2>
<p>You now have, hopefully, a fully working EPiServer development environment using your local IIS server. The one down side of this is that you may need to run Visual Studio as Administrator. This is due to requiring various privileges, but I think this is a small price to pay.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://xlevel.org.uk/setting-up-a-new-episerver-project-on-windows-7-and-iis7-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first steps with jQuery and ASP.Net &#8211; Part 2.</title>
		<link>http://xlevel.org.uk/my-first-steps-with-jquery-and-asp-net-part-2/</link>
		<comments>http://xlevel.org.uk/my-first-steps-with-jquery-and-asp-net-part-2/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 16:00:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://wp-test.xlevel.org.uk/?p=55</guid>
		<description><![CDATA[Converting HTML &#38; JavaScript to an ASP.Net control In the last post we created a image gallery control using HTML and JavaScript using the jQuery library. In this post we are going to take this control and turn it into &#8230;<p class="read-more"><a href="http://xlevel.org.uk/my-first-steps-with-jquery-and-asp-net-part-2/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<h2>Converting HTML &amp; JavaScript to an ASP.Net control</h2>
<p>In the last post we created a image gallery control using HTML and JavaScript using the jQuery library. In this post we are going to take this control and turn it into an ASP.Net control that can be used in an ASP.Net website or web application.</p>
<p>There are number of steps we are going to have to go through to wrap the HTML / JavaScript construct we created in the last post and render it out from an ASP.Net control.</p>
<p>The control needs to allow the web site designer to be able to modify various settings, such as the period between image changes and the fade out time. It needs to allow definition of the different images within the array and, lastly, render the modified the HTML and JavaScript.</p>
<p>Creating the basic ASP.Net control</p>
<p>We start by creating the <strong>FadingImageControl</strong>. This is a simple C# class which inherits from System.Web.UI.Control. To this we are going to add three properties;</p>
<ul>
<li><strong>Interval</strong> &#8211; This is the interval between image changes.</li>
<li><strong>FadePeriod</strong> &#8211; This is the time that images will take to fade in or out.</li>
<li><strong>CssClass</strong> &#8211; This is CSS class is added to the surrounding <strong>&lt;div&gt;</strong>. This allows the designer to CSS rules to modify the look and feel of the control.</li>
</ul>
<p><code><strong>namespace xLevel.Web.UI.WebControls</strong></code><br />
<code><strong>{</strong></code><br />
<code><strong> [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]</strong></code><br />
<code><strong> public sealed class FadingImageGallery : Control</strong></code><br />
<code><strong> {</strong></code><br />
<code><strong>  private string m_CssClass = string.Empty;</strong></code><br />
<code><strong>  private int m_Interval = 10000;</strong></code><br />
<code><strong>  private int m_FadePeriod = 2000;</strong></code></p>
<p><code><strong>  public int Interval</strong></code><br />
<code><strong>  {</strong></code><br />
<code><strong>   get { return m_Interval; }</strong></code><br />
<code><strong>   set { m_Interval = value; }</strong></code><br />
<code><strong>  }</strong></code></p>
<p><code><strong>  public int FadePeriod</strong></code><br />
<code><strong>  {</strong></code><br />
<code><strong>   get { return m_FadePeriod; }</strong></code><br />
<code><strong>   set { m_FadePeriod = value; }</strong></code><br />
<code><strong>  }</strong></code></p>
<p><code><strong>  public string CssClass</strong></code><br />
<code><strong>  {</strong></code><br />
<code><strong>   get { return m_CssClass; }</strong></code><br />
<code><strong>   set { m_CssClass = value; }</strong></code><br />
<code><strong>  }</strong></code><br />
<code><strong> }</strong></code><br />
<code><strong>}</strong></code></p>
<h3>Defining the image array</h3>
<p>With other ASP.Net controls where you define the contents of an array, this is done by creating sub controls within the main control, some thing like this;</p>
<p><code><strong>&lt;xlvl:FadingImageGallery ID="fig" runat="server"&gt;</strong></code><br />
<code><strong> &lt;xlvl:Image ImagePath="~/img/Duck-thumb.jpg" Title="Duck swimming in a pond."&gt;</strong></code><br />
<code><strong> &lt;xlvl:Image ImagePath="~/img/Dinghy-thumb.jpg" Title="Dinghy sailing on a lake."&gt;</strong></code><br />
<code><strong> &lt;xlvl:Image ImagePath="~/img/Gorse-thumb.jpg" Title="Gorse flowers."&gt;</strong></code><br />
<code><strong>&lt;/xlvl:FadingImageGallery&gt;</strong></code></p>
<p>To do this we need to first create the Image class. This class holds the image path and title values for the JSON style class array that defines the images to be displayed by the control. To allow for this we add two properties, <code><strong>ImagePath</strong></code> and <code><strong>Title</strong></code> and a constructor that allows these to properties to be defined, public <code><strong>Image(string title, string imagePath)</strong></code>.</p>
<p>Next, we add a new property to the <strong>FadingImageGallery</strong> to hold the image definitions. To do this, we create a generic <strong>List</strong> that we expose this through a getter only property called <strong>Images</strong>.</p>
<p>To allow only <strong>Image</strong> classes to be created inside the <strong>FadingImageGallery</strong> tag and to convert them into entries in the <strong>Images</strong> collection, we need to add a <strong>ParseChildren</strong> attribute to the class.</p>
<p><code><strong>[ParseChildren(true, "Images")]</strong></code></p>
<p>This tells ASP.Net to convert the all tags within the <strong>FadingImageGallery</strong> tags into <strong>Image</strong> classes and add them to the array exposed in the <strong>Images</strong> property.</p>
<h3>Modifying and rendering the controls JavaScript</h3>
<p>Lastly we need to enable the control to render the HTML and JavaScript that makes up the client side part of the control.</p>
<p>To do this, we need to override the <strong>CreateChildControls</strong> method. First we check if there any images in the <strong>Images</strong> property, if not, then there is no point creating the control.</p>
<p>If there are entries in the <strong>Images</strong> list, then we create a <strong>Panel</strong> control, which renders as a <strong>div</strong> and an <strong>Image</strong> control, which renders as a <strong>img</strong> tag. The <strong>Panel</strong> control is added to the local <strong>Controls</strong> collection, and the <strong>Image</strong> control is added to the <strong>Panel</strong>.</p>
<p>Next, we modify the JavaScript. The JavaScript functions are contained internally to the control as a string variable into which we then insert the <strong>Image</strong> control&#8217;s <strong>ClientID</strong>, the <strong>Interval</strong> and <strong>FadePeriod</strong> properties and the generated JSON style image array.</p>
<p>This string variable is then added to a <strong>InnerText</strong> property of a script tag that is then added to the <strong>Controls</strong> collection of the page&#8217;s <strong>Header</strong> section.</p>
<h2>Using the FadingImageGallery control</h2>
<p>To use the <strong>FadingImageGallery</strong> control in a web page we only need to do two things.</p>
<p>First, we need to register the <strong>xLevel.Web.UI.WebControls</strong> assembly in the page. This is done by adding the <strong>Register</strong> page directive to the top of the page.</p>
<p><code><strong>&lt;%@ Register TagPrefix="xlvl" Namespace="xLevel.Web.UI.WebControls"<br />
Assembly="xLevel.Web.UI.WebControls" /&gt;</strong></code></p>
<p>Next, we need to add a script tag to the page header to make sure the jQuery JavaScript library is accessible.</p>
<p><code><strong>&lt;script type="text/javascript" language="javascript"<br />
src="js/jquery-1.2.6.js"&gt;&lt;/script&gt;</strong></code></p>
<p>Now the page is ready for us to add the <strong>FadingImageGallery</strong> tag.</p>
<p><code><strong>&lt;xlvl:FadingImageGallery ID="fig" runat="server" &gt;</strong></code><br />
<code><strong>  ... </strong></code><br />
<code><strong> &lt;/xlvl:FadingImageGallery&gt;</strong></code></p>
<p>Lastly, we need to add an <strong>Image</strong> tag for each entry that will be switched between.</p>
<p><code><strong>&lt;xlvl:Image ImagePath="~/img/Duck-thumb.jpg"<br />
Title="Duck swimming in a pond." /&gt;</strong></code></p>
<h2>Available examples</h2>
<p>You can <a href="/wp-content/uploads/2008/12/Fading-Image-Gallery-Examplpe-Website.zip">download an example ASP.Net website</a> that uses the <strong>FadingImageGallery</strong> control.</p>
]]></content:encoded>
			<wfw:commentRss>http://xlevel.org.uk/my-first-steps-with-jquery-and-asp-net-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first steps with jQuery and ASP.Net &#8211; Part 1</title>
		<link>http://xlevel.org.uk/my-first-steps-with-jquery-and-asp-net-part-1/</link>
		<comments>http://xlevel.org.uk/my-first-steps-with-jquery-and-asp-net-part-1/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 19:11:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://wp-test.xlevel.org.uk/?p=33</guid>
		<description><![CDATA[Why start using jQuery with ASP.Net? I have been working with internet technologies now for over ten years and for most of those I have worked with Microsoft technologies, such as ASP or ASP.Net. For most of this time there &#8230;<p class="read-more"><a href="http://xlevel.org.uk/my-first-steps-with-jquery-and-asp-net-part-1/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<h2>Why start using jQuery with ASP.Net?</h2>
<p>I have been working with internet technologies now for over ten years and for most of those I have worked with Microsoft technologies, such as ASP or ASP.Net.</p>
<p>For most of this time there has always seamed to be a massive disconnect between the backend ASP or ASP.Net code and the front end HTML, CSS and JavaScript. I have often found that when people build sites using technologies like ASP.Net they ignore the power of JavaScript especially, instead either doing things through backend code or using another technology, such as Flash.</p>
<p>This is, I think, because:</p>
<ul>
<li>As most screen readers do not support JavaScript, any critical functionality that is implemented in JavaScript needs to also be implemented in backend code. This increases the development time.</li>
<li>Documentation on how to access the HTML rendered by ASP.Net controls via front end JavaScript is very limited</li>
<li>Most people find JavaScript development tools limited in their functionality and therefore development is more difficult than backend development using tools like Visual Studio.</li>
<li>Various browser implementations of JavaScript are massively different, this causes many compatibility headaches.</li>
</ul>
<p>This is why I was very interested in the announcement <a href="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx" target="_blank">announcement</a> that Microsoft where going to start shipping jQuery, the JavaScript library, with Visual Studio. This should be a real boast to JavaScript integration with ASP.Net and means ASP.Net developers have no excuse now not to learn JavaScript.</p>
<h2>Creating a Fading Gallery control.</h2>
<p>Part of a project I was asked to quote for included changing an existing Flash movie, where company logo&#8217;s where faded in and out every few seconds in a random order. As I&#8217;m not a Flash developer I got the idea to re-develop the movie using JavaScript and this is where the idea for this post came from.</p>
<p>The first advantage I could see of using JavaScript over Flash was that Flash is a black box where accessibility and SEO are concerned. With a JavaScript solution, the JavaScript would be used to modify a standard HTML tag, therefore it would be its own accessible fallback if JavaScript was disabled or unsupported.</p>
<h3>The HTML construct</h3>
<p>The HTML construct for this solution is very simple, being just an <code><strong>img</strong></code> tag within a <code><strong>div</strong></code>.</p>
<p><code><strong>&lt;div&gt;<br />
&lt;img id="image1" src="./Duck-thumb.jpg" alt="Duck swimming in a pond." title="Duck swimming in a pond." width="300" height="200" /&gt;<br />
&lt;/div&gt;</strong></code></p>
<h3>Personalizing the controls</h3>
<p>Part 2 of this post will be about wrapping this HTML and JavaScript as an ASP.Net control. Therefore, when designing the JavaScript code it was important to make it easy to specify the values that the designer will want to personalize. All of these values where declared as variables, allowing values to be inserted when the controls HTML and JavaScript code is generated.</p>
<p><code><strong>var imageId = '#image1';<br />
var interval = 10000;<br />
var fadeTime = 2000;</strong></code></p>
<p><code><strong>var crtImg = 0;<br />
var imgs = [{image: './Duck-thumb.jpg', text: 'Duck swimming in a pond.'},<br />
{image: './Dinghy-thumb.jpg', text: 'Dinghy sailing on a lake.'},<br />
{image: './Gorse-thumb.jpg', text: 'Gorse flowers.'}];</strong></code></p>
<p>Through these values it is possible to personalize the control by specifying the id of the img control, this is necessary as ASP.Net controls modify the id of controls they generate to guarantee that they are unique, the interval between fades, and the length of the fade and the array of images to be displayed.</p>
<h3>Starting the gallery</h3>
<p>We will want the gallery to start working immediately the page finishes loading. Luckily jQuery has a function that executes on Page Load, the <code><strong>$(function(){...});</strong></code> construct. Normally this method is used to wire up any event handlers, etc. Here we call the setTimeOut function. When the specified time interval is over, the <code><strong>fadeOutFunction</strong></code> function is called.</p>
<p><code><strong>$(function()<br />
{<br />
setTimeout('fadeOutFunction()', interval);<br />
});</strong></code></p>
<h3>Fading the image</h3>
<p>First we start by fading the image out. jQuery has two functions , <code><strong>fadeOut()</strong></code> and <code><strong>fadeIn()</strong></code>, that will change the specified tags opacity over a specified time period.</p>
<p>With jQuery you can use CSS style selectors to retrieve the require tag. In this example, <code><strong>$(imageId)</strong></code>, where imageId is the string <code><strong>'#image1'</strong></code>, it is used to select the img tag.</p>
<p>The <code><strong>fadeOut()</strong></code> function is executed on this <code><strong>img</strong></code> tag. You can also specify both a fade out period and a function to be executed after the fade out has finished. To make sure that everything happens in the right order the image change and fade in are specified in the function <code><strong>fadeInFunction()</strong></code>, which is called after the fade out has finished.</p>
<p><code><strong>function fadeOutFunction()<br />
{<br />
$(imageId).fadeOut(fadeTime, fadeInFunction);<br />
}</strong></code></p>
<h3>Doing the image switch</h3>
<p>Once the image has faded out, another image definition is randomly selected. To make sure that the same image is not shown twice in a row, we keep a track of the last image number shown and repeat the random selection until another number is returned.</p>
<p><code><strong>function fadeInFunction();<br />
{<br />
var imgId;<br />
do {<br />
imgId = Math.round(Math.random()*imgs.length);<br />
if(imgId == imgs.length) imgId = 0;<br />
}while (imgId == crtImg)<br />
crtImg = imgId;</strong></code></p>
<p>Next we need to change the <code><strong>img</strong></code> tag&#8217;s source, alternative text and title attributes. To do this we use the jQuery <code><strong>attr()</strong></code> function. jQuery allows you to chain function calls one after another on a single line of code. Here we use this technique to change the <code><strong>src</strong></code>, <code><strong>alt</strong></code> and <code><strong>title</strong></code> attributes of the tag in one easy to read line of code.</p>
<p>After this we just need to fade the <code><strong>img</strong></code> tag back into view, using the <code><strong>fadeIn()</strong></code> function.</p>
<p><code><strong>$(imageId).attr('src', imgs[crtImg].image).attr('alt', imgs[crtImg].text)<br />
.attr(';title', imgs[crtImg].text);<br />
$(imageId).fadeIn(fadeTime);<br />
setTimeout('fadeOutFunction()', interval);<br />
}</strong></code></p>
<p>The JavaScript timer functionality needs to be reset after the period expires. To make the process continuous we need to call <code><strong>setTimeout()</strong></code> again before we finish.</p>
<h2>The front end finished</h2>
<p>At this point we have our HTML/JavaScript construct working. In part 2 of the post we look at wrapping this front end control up as an ASP.Net control and allowing designers to personalize it.</p>
<p>Once the control is finished you will be able to configure it&#8217;s settings either from within front end code or via the design view, within the ASPX page.</p>
<p>You can download example code files of the HTML and JavaScript here.</p>
]]></content:encoded>
			<wfw:commentRss>http://xlevel.org.uk/my-first-steps-with-jquery-and-asp-net-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to style a HTML Form button as a Hyperlink using CSS</title>
		<link>http://xlevel.org.uk/how-to-style-a-html-form-button-as-a-hyperlink-using-css/</link>
		<comments>http://xlevel.org.uk/how-to-style-a-html-form-button-as-a-hyperlink-using-css/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 18:40:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://wp-test.xlevel.org.uk/?p=39</guid>
		<description><![CDATA[The first question that most people have asked me is, &#8220;Why would you want to?&#8221; The answer is because I want to cause a form post back and the control needs to be styled like a hyperlink. If you build &#8230;<p class="read-more"><a href="http://xlevel.org.uk/how-to-style-a-html-form-button-as-a-hyperlink-using-css/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>The first question that most people have asked me is, &#8220;Why would you want to?&#8221;</p>
<p>The answer is because I want to cause a form post back and the control needs to be styled like a hyperlink.</p>
<p>If you build websites using ASP.Net and C#, you have three controls that can do this, the standard form button, the image button and the hyperlink button.</p>
<p>The obvious choice would be the hyperlink button. This, however, has a fundamental flaw; it does not work when the user has JavaScript disabled. Many disabled Internet users require the use of applications that do not support JavaScript. This is why the WCAG accessibility guidelines say that the site should still be useable without JavaScript. This is practice means that JavaScript can only be used for non essential functionality and cannot be used for submitting a form.</p>
<h2>What web browsers will this work with?</h2>
<p>The following CSS has been tested with Internet Explorer 6 and 7, FireFox 2 and 3 and Safari 3, all on Windows. These are the standard supported browsers platforms most developers need to support, however I cannot see a reason why it should not work on other operating systems.</p>
<h2>Building the basic form</h2>
<p>To test the CSS I created a basic HTML page containing a simple form. The form contained just a button and a hyperlink, so that is easy to compare how the two controls are rendered.</p>
<p>The basic HTML was:</p>
<p><code><strong>&lt;form action="Button-to-link.htm"&gt;</strong></code><br />
<code><strong>  &lt;div&gt;</strong></code><br />
<code><strong>   &lt;button id="buttonLink" class="button-link link"&gt;Button Link&lt;/button&gt;</strong></code><br />
<code><strong>   &lt;a href="http://www.google.co.uk/" class="standard-link link"&gt;Standard Link&lt;/a&gt;</strong></code><br />
<code><strong>  &lt;/div&gt;</strong></code><br />
<code><strong> &lt;/form&gt;</strong></code></p>
<p>The <code><strong>button-link</strong></code> css class is designed to allow targeting of button specific rules, where as the <code><strong>link</strong></code> class is for more general rules.</p>
<h2>Removing the styling from an HTML button.</h2>
<p>As anyone who has tried to use standards based web development techniques will know, the different browsers will rended HTML elements in different ways. Not only that, but they will often apply CSS rules differently.</p>
<p>From experience buttons and other form element are where the browsers most often differ in their interpriation of CSS rules. However, there are a number of basic things we can do that will work across all the browsers we are supporting.</p>
<p>The main thing that makes a button look different from a hyperlink are the border and grey background. These can be removed using <code><strong>border: none</strong></code> and <code><strong>background-color: transparent</strong></code>. This leaves the button text black, sans-serif and smaller than the hyperlink.</p>
<p>As most designs tend to change the styling of hyperlinks from blue underlined text, I have used the <code><strong>link</strong></code> CSS class to style the font settings so that the hyperlink text and button text render the same. In this case I have choosen red Arial text of normal font weight and 1 em in size.</p>
<div id="attachment_41" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-41 " title="IE7-image-1" src="http://wp-test.xlevel.org.uk/wp-content/uploads/2011/12/IE7-image-1.png" alt="The test page rendered in Internet Explorer after removing the button styling." width="300" height="220" /><p class="wp-caption-text">The test page rendered in Internet Explorer after removing the button styling.</p></div>
<div id="attachment_48" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-48 " title="FireFox3-image-1" src="http://wp-test.xlevel.org.uk/wp-content/uploads/2011/12/FireFox3-image-1.png" alt="The test page rendered in FireFox after removing the button styling." width="300" height="220" /><p class="wp-caption-text">The test page rendered in FireFox after removing the button styling.</p></div>
<div id="attachment_44" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-44" title="Safari-image-1" src="http://wp-test.xlevel.org.uk/wp-content/uploads/2011/12/Safari-image-1.png" alt="The test page rendered in Safari after removing the button styling." width="300" height="220" /><p class="wp-caption-text">The test page rendered in Safari after removing the button styling.</p></div>
<p>&nbsp;</p>
<p><code><strong>&lt;style type="text/css"&gt;</strong></code><br />
<code><strong> .button-link</strong></code><br />
<code><strong> {</strong></code><br />
<code><strong>  border: none;</strong></code><br />
<code><strong>  background-color: transparent;</strong></code><br />
<code><strong> }</strong></code><br />
<code><strong> .link</strong></code><br />
<code><strong> {</strong></code><br />
<code><strong>  color: red;</strong></code><br />
<code><strong>  font-size: 1em;</strong></code><br />
<code><strong>  font-weight: normal;</strong></code><br />
<code><strong>  font-family: Arial;</strong></code><br />
<code><strong> }</strong></code><br />
<code><strong> &lt;style&gt;</strong></code></p>
<p>Making the unstyled button look like a link</p>
<p>After removing the button specific styling, you now need to make the button look like a link.</p>
<p>HTML buttons have space around the text. In Safari and Firefox this can be removed by setting the padding to 0. This doesn&#8217;t work for Internet Explorer. The only way there seams to be remove extra space is to explicitely set the width of the button to the size of the text. When doing this, use em&amp;rsquo;s as the unit of measurement. This allows the button size to grow in proportion to the font size.</p>
<p>At this point you will find that Internet Explorer renders the button text higher than the hyperlink text. To lower the link content we set <code><strong>position: relative</strong></code> and the <code><strong>top: 2px</strong></code> to bring them into alignment.</p>
<div id="attachment_42" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-42" title="IE7-image-2" src="http://wp-test.xlevel.org.uk/wp-content/uploads/2011/12/IE7-image-2.png" alt="The test page rendered in Internet Explorer after setting the width and repositioning the text." width="300" height="220" /><p class="wp-caption-text">The test page rendered in Internet Explorer after setting the width and repositioning the text.</p></div>
<div id="attachment_49" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-49" title="FireFox3-image-2" src="http://wp-test.xlevel.org.uk/wp-content/uploads/2011/12/FireFox3-image-2.png" alt="The test page rendered in FireFox after removing the padding." width="300" height="220" /><p class="wp-caption-text">The test page rendered in FireFox after removing the padding.</p></div>
<div id="attachment_45" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-45" title="Safari-image-2" src="http://wp-test.xlevel.org.uk/wp-content/uploads/2011/12/Safari-image-2.png" alt="The test page rendered in Safari after removing the padding." width="300" height="220" /><p class="wp-caption-text">The test page rendered in Safari after removing the padding.</p></div>
<p><code><strong>&lt;style type="text/css"&gt;</strong></code><br />
<code><strong> .button-link</strong></code><br />
<code><strong> {</strong></code><br />
<code><strong>  border: none;</strong></code><br />
<code><strong>  background-color: transparent;</strong></code><br />
<code><strong>  text-decoration: underline;</strong></code><br />
<code><strong>  padding: 0;</strong></code><br />
<code><strong> }</strong></code><br />
<code><strong> .link</strong></code><br />
<code><strong> {</strong></code><br />
<code><strong>  color: red;</strong></code><br />
<code><strong>  font-size: 1em;</strong></code><br />
<code><strong>  font-weight: normal;</strong></code><br />
<code><strong>  font-family: Arial;</strong></code><br />
<code><strong> }</strong></code><br />
<code><strong> &lt;style&gt;</strong></code></p>
<p><code><strong> &lt;!--[if IE]&gt;</strong></code><br />
<code><strong> &lt;style type="text/css"&gt;</strong></code><br />
<code><strong> .button-link</strong></code><br />
<code><strong> {</strong></code><br />
<code><strong>  position: relative;</strong></code><br />
<code><strong>  top: 2px;</strong></code><br />
<code><strong>  /* This needs to be specified for each button */</strong></code><br />
<code><strong>  width: 5.3em;</strong></code><br />
<code><strong> }</strong></code><br />
<code><strong>&lt;/style&gt;</strong></code><br />
<code><strong> &lt;![endif]--&gt;</strong></code></p>
<h2>Getting the text to display underlined.</h2>
<p>If you want your hyperlinks without the text underlined, then you can remove the <strong>text-decoration: underline</strong> and the button and the hyperlink will look the same and work correctly.</p>
<p>Unfortunately, in the acessibility guidelines they say you should keep links underlined, as people with colour blindness may not be able to pick out the link just from a colour difference. As acessibility is the main reson for doing this, it means we are going to have to try and fix this.</p>
<p>We cannot just use the <code><strong>text-decoration: underline</strong></code> because it does not render correctly in any browser but Safari.</p>
<ul>
<li>FireFox ignores the <code><strong>text-decoration: underline</strong></code> rule for the button.</li>
<li>Internet Explorer seams to render the underline closer to the bottom of the text.</li>
</ul>
<p>The simple answer to getting a consistant underline is to use a background image. To get this image to position correctly when the font height changes, and because the line is in slightly different places on Internet Explorer, Safari and FireFox, you will need to images. Firefox and Safari need a 3 pixel high background with the top pixel colored to the same as the font. Internet Explorer needs a 4 pixel high image.</p>
<div id="attachment_43" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-43" title="IE7-image-3" src="http://wp-test.xlevel.org.uk/wp-content/uploads/2011/12/IE7-image-3.png" alt="The test page rendered in Internet Explorer after adding the background image." width="300" height="220" /><p class="wp-caption-text">The test page rendered in Internet Explorer after adding the background image.</p></div>
<div id="attachment_40" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-40" title="FireFox3-image-3" src="http://wp-test.xlevel.org.uk/wp-content/uploads/2011/12/FireFox3-image-3.png" alt="The test page rendered in FireFox after adding the background image." width="300" height="220" /><p class="wp-caption-text">The test page rendered in FireFox after adding the background image.</p></div>
<div id="attachment_46" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-46" title="Safari-image-3" src="http://wp-test.xlevel.org.uk/wp-content/uploads/2011/12/Safari-image-3.png" alt="The test page rendered in Safari after adding the background image." width="300" height="220" /><p class="wp-caption-text">The test page rendered in Safari after adding the background image.</p></div>
<p><code><strong>&lt;style type="text/css"&gt;</strong></code><br />
<code><strong> .button-link</strong></code><br />
<code><strong> {</strong></code><br />
<code><strong>  border: none;</strong></code><br />
<code><strong>  background-color: transparent;</strong></code><br />
<code><strong>  background: url(red-dot.gif?v=2.4.0.43) repeat-x bottom;</strong></code><br />
<code><strong>  padding: 0;</strong></code><br />
<code><strong> }</strong></code><br />
<code><strong> .link</strong></code><br />
<code><strong> {</strong></code><br />
<code><strong>  color: red;</strong></code><br />
<code><strong>  font-size: 1em;</strong></code><br />
<code><strong>  font-weight: normal;</strong></code><br />
<code><strong>  font-family: Arial;</strong></code><br />
<code><strong> }</strong></code><br />
<code><strong>&lt;/style&gt;</strong></code><br />
<code><strong> &lt;!--[if IE]&gt;</strong></code><br />
<code><strong> &lt;style type="text/css"&gt;</strong></code><br />
<code><strong> .button-link</strong></code><br />
<code><strong> {</strong></code><br />
<code><strong>  position: relative;</strong></code><br />
<code><strong>  top: 2px;</strong></code><br />
<code><strong>  /* This needs to be specified for each button */</strong></code><br />
<code><strong>  width: 5.3em;</strong></code><br />
<code><strong>  background: url(red-dot-ie.gif?v=2.4.0.43) repeat-x bottom;</strong></code><br />
<code><strong> }</strong></code><br />
<code><strong> &lt;/style&gt;</strong></code><br />
<code><strong> &lt;![endif]--&gt;</strong></code></p>
<h2>Credits</h2>
<p>I would just like to thank my ex-colleagues Ben and Jon for giving me the initial CSS that they had come up with. Without them it would have taken a lot longer to have got started.</p>
<h2> Update</h2>
<p>After getting feedback from a friend I found the if you change the IE specific CSS to:</p>
<p><code><strong>position: relative;</strong></code><br />
<code><strong>top: 2px;</strong></code><br />
<code><strong>overflow:visible;</strong></code><br />
<code><strong>background: url(red-dot-ie.gif?v=2.4.0.43)</strong></code><br />
<code><strong>repeat-x bottom;</strong></code></p>
<p>then this removes the need to set the width for each button.</p>
]]></content:encoded>
			<wfw:commentRss>http://xlevel.org.uk/how-to-style-a-html-form-button-as-a-hyperlink-using-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

