There are no set laws in the UK regarding Website Accessibility, but your website should at least meet Priority Level 1 and it is recommended to meet Priority Level 2.
Her is the link to Website Accessibility Level 1 (A) reference:
http://www.w3.org/WAI/WCAG20/quickref/Overview.php
Wednesday, 29 April 2009
Using multiple versions of browsers (IE + FF)
Internet Explorer
I found this handy tool, IETester, for testing your websites in multiple versions of IE, each in a different tab. Currently it can test IE 5.5, 6, 7 and 8 beta.
Since it's an early alpha release there is a list of known bugs on their homepage but it is good enough to view pages in.
Firefox
I found the easiest way of testing in various versions of FF was to use a portable version since it doesn't need any installation and won't mess with whichever current install you have.
You can find all portable legacy versions if FF here.
Tuesday, 28 April 2009
Extension Methods in C# 3.0
A new function of C# 3.0 is Extension Methods.
"Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type."
For example, if you wanted a method to convert a temperature from celsius to fahrenheit, where previously you would use
using extension methods you can now use
To do this you would create a new static class to contain the static method CelsiusToFahrenheit. The key to extension methods is passing in the this keyword along with the variable. For example,
This will now allow you to use the CelsiusToFahrenheit method on any integer variables.
You can also add methods to extend your own custom classes, and the methods can have different return types. For example, if you have your own class, TestClass, you can create a static method using extending TestClass, e.g.
Which will then allow you to use:
"Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type."
For example, if you wanted a method to convert a temperature from celsius to fahrenheit, where previously you would use
int temp = 30;
int i = myClass.CelsiusToFahrenheit(temp);
using extension methods you can now use
int temp = 30;
int i = temp.CelsiusToFahrenheit();
To do this you would create a new static class to contain the static method CelsiusToFahrenheit. The key to extension methods is passing in the this keyword along with the variable. For example,
public static class myClass
{
public static int CelsiusToFahrenheit(this int temp)
{
return (9 / 5) * temp + 32;
}
}
This will now allow you to use the CelsiusToFahrenheit method on any integer variables.
You can also add methods to extend your own custom classes, and the methods can have different return types. For example, if you have your own class, TestClass, you can create a static method using extending TestClass, e.g.
public static DateTime doSomething(this TestClass t)
{
//do something
}
Which will then allow you to use:
TestClass t = new TestClass();
DateTime x = t.doSomething();
Monday, 27 April 2009
jQuery events not firing for dynamic content
When adding dynamic content (using AJAX or DOM modification) using jQuery, events are not fired for the new objects, for example if you have the following html:
When I click the load button I want to add a link to another page inside the container DIV, so I use the following jQuery.
The click event for the dynamically created anchor tag (id="popup") will not fire using the above because this code is run once the document is ready, and at that time jQuery will look for an object with an Id of popup which doesn't exist yet.
I've found a few different ways to do this:
1. Add a generic click event for the body tag and check what was clicked, for example:
Using this example you check what was clicked using target.is(), you can use any valid CSS selector statements to check the item clicked. This way is simple to implement but can quickly grow if you have a lot of dynamic content.
2. Use the live command, which will tell jQuery to bind any current and future references of "#popup" to the click event.
The following 3 ways are variations on the same theme in that the events are bound after content creation.
3. Use the jQuery Bind command to bind the click event to a particular function on creation. e.g.:
4. Insert the function for handling the click event within the initial click event when you create the popup link. This runs the event binding as soon as the item is added.
5. Similar to the above method except this way you create a method which does all data binding (bindEvents()). This can be useful if you have a lot dynamic content that needs to be bound at the same time, it can be encapsulated into 1 event.
There's also a plugin called livequery that makes binding easier.
<button id="load" href="#">Test</button>
<div id="container"></div>
When I click the load button I want to add a link to another page inside the container DIV, so I use the following jQuery.
$(function() {
$("#load").click(function() {
$("#container").html("<a id='popup' href='contactForm.html'>popup</a>")
});
$("#popup").click(function(){
alert("Clicked");
return false;
});
});
The click event for the dynamically created anchor tag (id="popup") will not fire using the above because this code is run once the document is ready, and at that time jQuery will look for an object with an Id of popup which doesn't exist yet.
I've found a few different ways to do this:
1. Add a generic click event for the body tag and check what was clicked, for example:
$("body").click(function(e){
var target = $(e.target);
if (target.is("#popup")) {
alert("Clicked");
return false;
}
});
Using this example you check what was clicked using target.is(), you can use any valid CSS selector statements to check the item clicked. This way is simple to implement but can quickly grow if you have a lot of dynamic content.
2. Use the live command, which will tell jQuery to bind any current and future references of "#popup" to the click event.
$("#popup").live("click",function(){
alert("Clicked");
return false;
});
The following 3 ways are variations on the same theme in that the events are bound after content creation.
3. Use the jQuery Bind command to bind the click event to a particular function on creation. e.g.:
$("#load").click(function(){
$("#container").html("<a id='popup' href='contactForm.html'>popup</a>").bind('click', loadClick);
//can also use
//$("#container").html("<a id='popup' href='contactForm.html'>popup</a>").click(loadClick);
});
function loadClick(){
alert("Clicked");
return false;
}
4. Insert the function for handling the click event within the initial click event when you create the popup link. This runs the event binding as soon as the item is added.
$("#load").click(function(){
$("#container").html("<a id='popup' href='contactForm.html'>popup</a>");
$("#popup").click(function(){
alert("Clicked");
return false;
});
});
5. Similar to the above method except this way you create a method which does all data binding (bindEvents()). This can be useful if you have a lot dynamic content that needs to be bound at the same time, it can be encapsulated into 1 event.
$("#load").click(function(){
$("#container").html("<a id='popup' href='contactForm.html'>popup</a>");
bindEvents();
});
function bindEvents(){
$("#popup").click(function(){
alert("Clicked");
return false;
});
};
There's also a plugin called livequery that makes binding easier.
Sunday, 26 April 2009
Firebug for all browsers!
When designing websites I've found firebug for FireFox invaluable for checking out exactly what's going on. I've now found you can get Firebug lite for use on any browser!
It's very easy to use, all you have to do is include the following code in any page that you want to use it in:
Genius.
It's very easy to use, all you have to do is include the following code in any page that you want to use it in:
<script type="'text/javascript'" src="%27http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js%27"></script>
Genius.
Thursday, 9 April 2009
jQuery Intellisense for Visual Studio
The mighty Guthrie explains all....
http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx
http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx
Wednesday, 1 April 2009
TSQL script to loop round all databases
Hi Guys
Quick script to loop round all databases and perform an action - in this case its setting all databases to simple recovery. The keyword here is sp_msforeachdb - pure genius :)
use master
GO
sp_msforeachdb '
declare @sql VARCHAR(1000)
IF DATABASEPROPERTYEX(''?'', ''Rjavascript:void(0)ecovery'') <> ''SIMPLE''
begin
set @sql = ''ALTER DATABASE ? SET RECOVERY SIMPLE''
PRINT @sql
end'
Quick script to loop round all databases and perform an action - in this case its setting all databases to simple recovery. The keyword here is sp_msforeachdb - pure genius :)
use master
GO
sp_msforeachdb '
declare @sql VARCHAR(1000)
IF DATABASEPROPERTYEX(''?'', ''Rjavascript:void(0)ecovery'') <> ''SIMPLE''
begin
set @sql = ''ALTER DATABASE ? SET RECOVERY SIMPLE''
PRINT @sql
end'
Subscribe to:
Posts (Atom)