Category Archive for: ‘Tech / Work’

Property Access Modifiers in Whidbey

0

Ooh, this is great news:


http://nxopinion.robertsoninstitute.org/blogs/rcecil/archive/2004/11/11/167.aspx


It’s a little thing, to be sure, but I often find myself wanting to make a setter internal or private while leaving the getter public.  So, I’m happy.  It doesn’t take much :-)

Oooh, more VS.NET toys

0

Scott Hanselman’s list of Ultimate Visual Studio .NET add-ins.  I’m gonna have some fun with these.  Hey, I never knew that Reflector was available as a VS add-in – cool!

Custom Email Publisher for Microsoft Exception Management Application Block

0

I’ve finally taken the time to have a good look at the MS Exception Management Application Block and I like what I see – I wish I’d incorporated it into my apps years ago instead of hardcoding ugly inflexible exception handling routines from scratch.  Ah well, you live and learn.  The default publisher supplied  logs exceptions to the Event Log, but for most of my apps I’d much rather receive an email when an error occurs – this way it’s possible to be a little more proactive and contact the customer who experienced a problem before they get in touch.  To this end I’ve created a Custom Email Publisher based on the default publisher – it’s downloadable here [2.24kb] if you’re interested.  Combine this with a customised base application exception containing properties for the application user’s name and phone number and you’re laughing.

Source download [2.24kb]

nHibernate

0

There’s so much good open-source .Net development going on these days – .Text, nGallery, nUnit, etc - it’s a really interesting time to be a developer.  My colleague Colin just drew my attention to nHibernate, an object persistence library for relational databases.  TheServerSide.net has an excellent article summarising its use.  Having just finished a long project where a large amount of time was spent writing "plumbing" code to persist objects to and from a SQL Server database, I’m finding the idea of using an O/R mapper such as this very appealing the next time round.  Just as incorporating the MS DAAB block into solutions has reduced the amount of data access code required, I’m hopeful that embracing frameworks such as nHibernate will leave us with more time to spend focusing on addressing the business needs and less on re-solving technical issues.

If anyone has had experience of using nHibernate or similar O/R mapper in an enterprise .NET project, I’d be interesting in hearing your opinions.  Would you use it again?  Did it genuinely help to abstract away the object persistence/retrieval mechanisms from the domain model, or is it just one more layer to worry about and keep up to date?  Let me know.

VS Team System preview is on MSDN

0

Rick LePlante reports that a preview of VS Team System is now available for download to MSDN subscribers.  I’ve been desperate to try this, but at 3.39Gb this download could take me a while, and if it’s anything like the beta 2 of SQL Server 2005 I suspect I’ll discover that my aging PCs don’t have sufficient power to run it.  Ah, the relentless march of progress…

IE team are blogging

0

The recently re-formed IE team now have a blog.  Although I prefer to use Firefox for personal use, there’s no escaping IE on the corporate desktop (at which my ASP.NET apps are invariably targetted), so this is a useful and interesting way to get some inside info on what is planned for IE7.  Of course I hope it’ll include better standards support, but I fear I’ll be working around IE’s quirky behaviour for many years to come..


I like the comment about IE6 being the Courtney Love browser in a world of Kirsten Dunsts – now that’s funny :-)

70-320 is tough :-(

0

Flush from my recent success on the 70-229 SQL Server exam I’ve been studying for 70-320 – XML Web Services and Server Components, the syllabus of which is much tougher!  Maybe it’s just that I have been using SQL Server 2000 for serveral years now, whereas some of subject matter in the 70-320 exam is new to me.  I’m enjoying learning most of it, and finding a lot of it useful, but some stuff seems needlessly esoteric – am I really ever likely to want to write a server-side SOAP extension in my day job?  I think not.

Inheriting from BaseValidator to make custom validation controls

0

For months now, I’ve been desperate for a decent excuse to make a custom ASP.NET server control, so I was secretly pleased today when a CustomValidator originally coded for use on a single page was required elsewhere.

It’s surprisingly easy to do, although it took me a while to find a decent example online, which eventually came courtesy of the 4GuysFromRolla. In my particular scenario, I needed to check that the text entered into a TextBox did not equal any of a selection of "banned" strings (which was available via a static property on another class).

Having added a new custom web control, deriving from BaseValidator, my first task was therefore to ensure that the control being validated really was a TextBox – this was done by overriding the ControlPropertiesValid() method:

///
/// This method checks whether the control set in the
///   ControlToValidate property is valid.
///
/// Boolean indicating whether we have a valid ControlToValidate
protected override bool ControlPropertiesValid()
{
// Get the control we're trying to validate
Control ctrl = FindControl(ControlToValidate);
if (ctrl == null)
{
// If the control does not exist, throw an exception
throw new ApplicationException(string.Format(
"StringValidator - Control {0} could not be found to validate",
ControlToValidate));
}
else
{
// Try to cast the control to a Textbox
try
{
_textctrl = (TextBox)ctrl;
return true;
}
catch (InvalidCastException)
{
// Control doesn't appear to be a TextBox -
// throw an exception
throw new ApplicationException(string.Format(
"StringValidator - Control {0} is not a TextBox",
ControlToValidate));
}
}
}

That done, I just had to override the EvaluateIsValid() method, which does the actual validation:

///
/// Determine whether the text entered in the TextBox being
///  validated is allowed.
///
/// Boolean indicating whether the string
protected override bool EvaluateIsValid()
{
// Get dataview of invalid strings
DataView dvInvalidStrings = SiteTerms.InvalidStrings;
// Search dataview for the string entered in the TextBox
//  control being validated
dvInvalidStrings.RowFilter = string.Concat("[InvalidString] =
'",_textctrl.Text.ToString().Trim().Replace("'","''"),"'");
// Return false if any rows were found, otherwise true.
if (dvInvalidStrings.Count==0)
{
return true;
}
else
{
return false;
}
}

…and that was it. Job done, pretty much. OK, so I spent a while making a cute icon image too. But the coding was easy and straightforward – inheriting from BaseValidator meant that most of the work was already done for me. In no time at all I was able to drop this custom control onto the required pages and user controls.

Page 14 of 14« First...«1011121314