November 29th, 2007 Luke
I recently build a quick textbox-based login page, which worked fine - until we tested it under IE and the form wasn’t submitting properly. If a user entered text into the textbox and pushed enter(under IE), instead of submitting the form it would just refresh the page(although it would post a postback). It took a friend and I a little while to figure out, but we eventually managed (through some googling) to resolve the issue. If you add this:
<input type="text" style="display:none" />
To your form, IE will properly submit the form.
Who would have thought?
Posted in ASP.Net, bug, ie, snippet | No Comments »
November 22nd, 2007 Luke
This is a Perl snippet that will nicely format 10-digit phone numbers, so that they get returned in the form (xxx) xxx.xxxx:
sub formatPhoneNumber {
my $number = shift;
die "$number is not a valid 10-digit phone number" unless $number =~ /^\(?([1-9]\d{2})\)?[-., ]*?([1-9]\d{2})[-., ]*?(\d{4})$/;
my $formatted = "($1) $2.$3";
return $formatted;
}
Posted in perl, regex, snippet | No Comments »
November 21st, 2007 Luke
This is a short regular expression that will only match a valid phone number:
^\(?[1-9]\D*(\d\D*){2}\)*(\D)*[1-9]\D*(\d\D*){6}$
It will work on these numbers as input(and probably others, but I couldn’t think of anything else to test:
(111) 111-1111
1111111111
111 111.1111
111-111-1111
111111-1111
111.111.1111
It would be fairly easy to capture the numbers supplied and create a nicely formatted number out of any input supplied - I’ll put that regex up later.
Posted in regex, snippet | No Comments »
November 6th, 2007 Luke
I’ve encountered a situation where I need to populate a DropDownList with listItems programmatically.
As it turns out, this is easier than you’d think(but not immediately apparent). Here’s how you’d create a new listItem and append it to a *List element:
Dim item As New ListItem("My New Item!")
me.list_of_stuff.Items.Add(item)
And that’s it! Simple, eh?
Posted in ASP.Net, Code, snippet | No Comments »
November 5th, 2007 Luke
I’ve been working on getting some of my test project out of the door, and I’m at the point where I’m writing the database queries.
As it turns out, you are not allowed, under MSSQL, to use a column of the type text in a WHERE clause. It needs to be a varchar column.
Why? I have no idea.
Posted in SQL, migration | No Comments »