Hello world!
Posted on February 6th, 2010 • Filed under Uncategorized • 1 Comment
Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
Setting a labels "for" attribute inside a repeater
Posted on November 15th, 2009 • Filed under asp.net • No Comments
It’s nice to add <labels> to your form fields and set the labels “for” attribute so that it references the field it is a label for.
e.g.
<label for="emailaddress">Email</label>
<input type="text" id="emailaddress"/>
Now if you’re referencing asp.net controls you can use the clientid property.
e.g.
<label for="<%= emailaddress.clientid()%>">Email</label>
<asp:TextBox runat="server" ID="emailaddress" />
All nice an easy so far. The situation gets a [...]
MySql and the Art of Sql
Posted on July 2nd, 2009 • Filed under MySql • No Comments
I’ve been reading the The Art of SQL and it makes some very sensible suggestions regarding query performance.
Here’s somewhere I’ve implemented 1 of the techniques.
The task: return records for this month.
Usually I’d write something like
select * from results where month(dateadded) = month(now()) and year(dateadded) = year(now())
The problem with this is that 2 functions (month() and year()) [...]
Import csv data into MySql
Posted on May 8th, 2009 • Filed under MySql • No Comments
Unusually for an asp.net developer, MySql is my database platform of choice – very quick and less server intensive that certain other database platforms I could mention…
Anyway here’s how I go about loading csv data into MySql
Prepare your data in a program such as excel or open office
Save as comma delimied or tab delimited in the [...]
jQuery and asp.net validation controls
Posted on April 11th, 2009 • Filed under Javascript, asp.net • 1 Comment
Just found a nice tip to check with jQuery if all built-in asp.net validation controls on a form are valid.
As an asp.net developer and jQuery advocate I know I’m going to find this tip very useful
http://devoma.com/post/JQuery-and-ASPNET-validators.aspx
Case insensitive xpath queries
Posted on April 6th, 2009 • Filed under xml • No Comments
I had an xpath query to test whether a node already exists in an xml document
Dim KeyphraseNode As XmlNode = xmlDoc.SelectSingleNode( _
String.Format("/websites/website[@url='{0}']/keyphrases/keyphrase[@value='{1}' and @type='{2}']" , _
WebsiteUrl, keyphrase.ToLower, keyphraseType))
Unfortunately users were testing for values with different capitalisations so the program was reporting that the nodes didn’t exist when actually they did.
I could have change the data [...]
asp.net viewstate and seo
Posted on March 18th, 2009 • Filed under asp.net • No Comments
asp.net viewstate is a wonderful invention, but can bloat your html. For most users this is probably going to have minimal impact on the page load time. But for search engines spiders you really want to minimise needless information, especially near the top of the page.
It’s best practice to turn off viewstate for the whole [...]
ASP.NET Event Validation and “Invalid Callback Or Postback Argument”
Posted on February 5th, 2009 • Filed under Javascript, asp.net • No Comments
I was getting this and pulling my hair out.
My button (server-side) was pumping out a bit of javascript
Page.ClientScript.RegisterStartupScript(GetType(String),
"loginunsuccessful", "<script type=""text/javascript"">
alert(‘Login unsuccessful – please try again’);</script>")
And this kept causing the error.
I tried using the prescribed fix: ClientScript.RegisterForEventValidation(mycontrol.uniqueid) in the prerender. Still got the error.
Here’s how I fixed it. RegisterStartupScript does the [...]
Use jQuery to replace <body onunload="GUnload()">
Posted on January 26th, 2009 • Filed under Javascript • 6 Comments
When using Google maps it’s important to use GUnload on the page’s unload event. Fine when you can access the body tag directly…. But if you have the Google map functionality wrapped inside an ascx you need a different approach.
After a big of digging I found how to use jQuery to “catch” the [...]
Need to access session variables in an ashx?
Posted on January 16th, 2009 • Filed under asp.net • 1 Comment
Just a quick note if you need to access session variables from an ashx, you need to implement SessionState.IRequiresSessionState or IReadOnlySessionState if you only need to read the vars
In your ashx change
Public Class yourclass : Implements IHttpHandler
Implements SessionState.IRequiresSessionStat
to
Public Class yourclass
Implements IHttpHandler
Implements SessionState.IRequiresSessionStat