I’ve just been reading up on mocks for testing and they look like a pretty neat and powerful way to improve your testing. I’ve written this sample code based on the example Martin Fowler gives in his excellent article.
This example is of an order which attempts to fullfil itself from a Warehouse. Here’s the Warehouse [...]
Normally if you were trying to sort a DataTable you would do see something like
[csharp]
DataTable table = retrieveTable();
DataView view = new DataView(table);
view.Sort = “Name”;
datagrid1.DataSource = view;
datagrid1.DataBind();
[/csharp]
Doing this works fine for UI cases, but if you need to get access to the sorted table you’ll want to do this.
[csharp]
DataTable unsortedTable = retrieveTable();
DataTable sortedTable = new DataTable();
foreach [...]
In your ASPX page, add the following such that it renders in the top-right of the popup window
And add this code such that it renders in the bottom-left of the popup window
Then add the following Javascript to your page and make a call to resizeThisWindow().
// Default window dimensions to add to the size we ‘read’ [...]
Taken from this blog is a technique which will postback the form when you hit enter. If you use the script below, it will work in any browser (although bypassing any onClick code for the button specified).
[javascript]
function clickButton(e, buttonid)
{
var bt = document.getElementById(buttonid);
if (typeof bt == ‘object’)
{
try
{
if(navigator.appName.indexOf(”Netscape”)>(-1))
{
if (e.keyCode == 13)
{
bt.click();
return false;
}
}
if (navigator.appName.indexOf(”Microsoft Internet Explorer”)>(-1))
{
if (event.keyCode == [...]
Useful collection of string formats for .NET
String formatting in C#
So it’s late in the day and i’ve been working on the darned SQL Server Reporting for my latest project most of the day, but i’m sure that i’ve found a bug, rather than simply got confused.
I’ve got a report with a bunch of controls whose visibility i’d like to control from a parameter. Not [...]
Sometimes you need to pass multiple parameters into SQL Server Reporting Service.
Unfortunately Microsoft didn’t include this functionality in the first release, although they’re rumoured to be looking into this. This means that if you want to include a bunch of parameters and pass them through to an SQL ‘IN’ statement it’s a little awkward, but [...]
This will link to an external Javascript file. You need the charset attribute if your external file is using international symbols (e.g. £ or $). Also, don’t use inline regular expressions (var rex = /foo/gi;) instead use proper object definitions (var rex = new RegExp(”foo”, “gi”);)
<script charset=”ISO-8859-1″ type=”text/javascript” xsrc=”/money.js” mce_src=”/money.js”></script>
ASP.NET by default sniffs Firefox and incorrectly identifies it as being a down-level browser. This has the effect of emitting ’simple’ HTML without various CSS attributes. To fix it, view this blog and update your web.config (or machine.config if you have access).
The Code Project - The 30 Minute Regex Tutorial - .NET