Wednesday, 5 June 2013

Using the £ symbol in web.config

It's a long story as to why, but I needed to use the £ symbol in my web.config

On my local windows 7 IIS setup, it was happy to just use £. On our windows 2003 staging server, the same was true. But under Windows 2008, IIS threw it's teddy out of the pram and just errored saying invalid xml file.

A few places suggested using & pound; instead, but this did not work.

What did work though was using the unicode value of & # 163;

Tuesday, 30 October 2012

Row not found or changed

Today whilst working with what had been a stable piece of LINQ for some weeks, I had to use the data connection in a separate application. I thought this would be straightforward as I'd been using it in its current application for quite some time.

Upon trying to update a row, to merely save a string value, I received the "Row not found or changed" error.

Doing the usual Googling and finding many many people complaining about this on StackOverflow, I tried all the suggestions of changing the datefield in the table to never complain about it updating, checking that no count wasn't enabled for the database, re-dragging the table into the DBML to update it etc, but nothing seemed to work.

In final desperation, I just happened to be sat with SQL Management Studio open and that particular table expanded so I could see the fields, and also the dbml open and the what appeared to in the end be the offending field, properties open. I noticed that even though I had re-dragged the table to the DBML that the specification for nullable was different. On the server null was valid, but in the DBML it was Varchar(500) NOT NULL.

So there we have it. The row couldn't update because LINQ interpreted the definition it had to be different to the database.

And the strangest thing? I was trying to update it so that it wasn't null, and in the database there is a default value for it.

If you've come to brick wall with this, I hope this helps you too!

Thursday, 22 March 2012

ASP DataPager double click to move page

I have only just got around to using the .NET 4.0 DataPager control, and whilst impressed at the simplicity of setting it up, I was annoyed with two features:

1) You have to bind it to a ListView, it does not work with a Repeater control which is a little strange as exactly what I was achieving in the repeater I can do with no code change to get it to work in the ListView
2) When you want to page, say from page 1 to page 2 of the results, you have to double click the "next" button twice to move forward.

Nothing I can do about 1) above, but as for 2), just ensure that the listview it is being re-bound during the pagination by adding the OnPagePropertiesChanged attribute to the ListViews markup, e.g:


and in the code behind, bind on the event

protected void lstSearchResult_OnPagePropertiesChanged(object sender, EventArgs e)

Tuesday, 13 March 2012

Jquery ajax call to WCF stops working when upgrading to jquery 1.7.1

This had me puzzled for ages. When upgrading the version of jquery we use from 1.5 to 1.7.1 so that we could use Bootstrap popovers, any calls to our WCF .NET service would fail with a blank error message returned.

What I found was that within out Ajax call we had set:

jsonp: "callback", dataType: "json"

In 1.5 this worked fine, however in 1.7.1 it had noticed that the response type was supposed to be jsonp (JSON with padding) and thus bombing out with a mismatch.

Changing this to the correct format of:

jsonp: "callback", dataType: "jsonp" 

Fixed the problem.

Tuesday, 22 November 2011

Wordpress php.ini settings to load external url

A friend of mine had an issue with a vanilla wordpress install that he had that was using a premium theme.

Upon loading the theme, the page showed many errors relating to servers security setting would not allow the loading of data from external urls.

The information we were given was to set the php.ini in the directory of the calling page, so that the setting could be overridden - so we did, no change.

The solution is that the php.ini file in the wp-admin folder needs setting, not in the calling page, because the calling page in this case is a settings page itself that is being imported into the wp-admin/index.php file.

The settings in php.ini are then:

allow_url_fopen = 1
allow_url_include = 1

Wednesday, 4 May 2011

PHP .htaccess redirect

I have been helping a neighbour of mine who is an Optician in Spalding, and he was trying to make sure that when people were searching for "Opticians in Spalding" they would make sure that the old pages on his website that were already listed in Google, would still link through to his new site that he's spent ages on.

Being a windows server man, I know how to do this in IIS, but as his new website is hosted on a linux server, it needed to be compatible with that. So anyway, I found out that you can do 301 redirects on Apache using a .htaccess file.

In this case, it was real simple, create a blank file called .htaccess and the place an entry for each for each file that needs redirecting, i.e:

Redirect 301 /HTML/Consultations.htm

Excellent, and I now know that visitors to my local Optician in Spalding will still get there from any old bookmarks!

Tuesday, 1 March 2011

EventType clr20r3

I had this error today when trying to launch a .net application on a remote host machine. The file io exception threw me somewhat as it made me think that the issue was with loading a config file.

In fact the culprit of this error was not the config files, it was in fact missing dlls that are normally referenced from the GAC.

As I had no idea which dll it didn't know about, I just set each dlls reference to say copy to local = true, and then deployed the whole contents.