My name's Karl Alesbury, and I'm a C# ASP.NET contractor living in Bristol, UK. This blog is an attempt to sort out my coding gremlins or to post solutions on ridding the world of them.
Friday, 20 February 2015
asp:DropDownList - invalid postback or callback argument
This error is usually caused by something changing the contents of the drop down before postback, which gets .NET very confused.
In my case, it was due to white space in some of the drop down entries being bound. Using String.Trim() cleared this up.
Strangely, changing from a .NET drop down to a standard drop down (select tag) caused my getters to fetch an empty string instead of my value.
This sort of thing happens a lot with Umbraco properties, because quite a few of them are auto-padded with white space. Calling Trim() is a good practice in situations where you think you might get unnecessary padding.
Monday, 9 June 2014
Fire an event using JQuery with a delay
Monday, 26 May 2014
The E_INVALIDARG Visual Studio warning
I had a very strange compilation error occur the other day that was preventing me from starting my .NET project.
It read:
ASP.NET runtime error: Could not load file or assembly 'xxxx.yyyyy.zzzzzz, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxx' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Fix
Shut down IIS and Visual Studio, then clear the contents of all "C:\WINDOWS\Microsoft.NET\Framework\vx.x.x\Temporary ASP.NET" folders.
I found the fix for this problem on a MSDN blog article.Monday, 12 May 2014
Microsoft SQL Server Migration Assistant for MySQL does NOT support SQL Server Express!
Fairly recently, I was given a MySQL database and told that I needed to use the bulk of this data to power a web application that was using Microsoft SQL Server.
The first major task with this was finding a way of getting the tables across to a SQL Server format that I could work with, and I'd deal with the actual process of getting the data into my database later using a load of custom scripts.
I decided on using the Microsoft SQL Server Migration Assistant for MYSQL to do the heavy work for me, and now that I know what can go wrong with this process, I'd recommend that most users take this route.
Notes
Every time I ran the conversion tool on a database, the MSSQL Agent shut down
Don't use MS SQL Server Express edition as the destination DBMS. Make sure you use a fully qualified version of SQL Server; Developer Edition did it for me. You need a full version because SQL Server Express shuts the SQL Server Agent down and won't let it start again - Trying to get it started again is a RED HERRING. You think that the agent is stopping you from doing a successful import, but it's just one of many reasons. Get the proper version of SQL Server, and this will work straight away.
Nullable columns after creating the schema
Once the schema has been created within MSSQL, it's time to import data into your newly created tables. For some reason, when the migration assistant created the SQL Server tables, it didn't make the columns that needed to be nullable, well, nullable. So you have to do that by hand. The easiest way to spot it is when your migration falls over because it's trying to insert a null value into your table.
Get the MYSQL ODBC plugin
You can get a list of ODBC plugins at the MYSQL website. This is how MYSQL and MSSQL know how to talk to each other.
Monday, 28 April 2014
Slow publishing times on Umbraco sites and the Umbraco SiteMapProvider
Wednesday, 13 February 2013
Get a list of countries for a dropdown
It appears that there are in fact a large amount of incorrect / incomplete answers on the subject.
There is a web service that you could add and call which may prove to be more up-to-date than the .NET framework itself, but the easiest, fastest and WORKING method of adding countries to a drop-down is to use the method mentioned in this StackOverflow question:
It's a life-saver!
Thursday, 3 January 2013
You get "Maximum request length exceeded" when you upload big files
If you're using IIS 7, a lot of answers online seem to point to increasing the maxAllowedContentLength attribute for the requestLimits element in the web.config.
Others also say if you're using IIS 6, you need to increase the maxRequestLength attribute for the httpRuntime element, also in the web.config.
I had to do both.
Within <system.web>, add:
And within <system.webServer>, add:
IMPORTANT:
Both of these values must match. In this case, my max upload is 1024 megabytes.
maxRequestLength has 1048576 KILOBYTES, and maxAllowedContentLength has 1073741824 BYTES.
It's quite easy to overlook this difference in requirements for each attribute, and mismatching these values can cause other errors.
I also answered this question on StackOverflow.