Three posts in one morning? Wow. I’d meant to post this earlier, but with one thing and another…
ASP.NET renames your controls.
I discovered this while, once again, working with the dreadful ITS component of SAP. It needs fields named TABLE_NAME-FIELD_NAME. Note the hyphen. Obviously, if you try to create a control with that Id, .NET complains. So I did the following:
<input type="hidden" name="TABLE_NAME-FIELD_NAME" id="TABLE_NAME_FIELD_NAME" runat="server">
So it’s got a .NET compatible Id but an ITS-compatible name. Great solution, huh?
No. I couldn’t get it working. ITS wasn’t picking up the value coming through from the fields. When I viewed the HTML generated by my page I found out why:
<input type="hidden" name="TABLE_NAME_FIELD_NAME" id="TABLE_NAME_FIELD_NAME" runat="server">
In other words, it changed the name of my control to make it match the id. Now I can kind of understand that. When a form submits, you get name-value pairs on the server side, and .NET would obviously prefer to have the id matching the name. On the other hand, RadioButton controls already have a different id to the name, so why can’t .NET be clever enough to deal with other controls doing the same?
Anyway. I came up with a rather hacky solution to this one. My HTML now looks like this:
<input type="hidden" ProperName="TABLE_NAME_FIELD_NAME" id="TABLE_NAME_FIELD_NAME" runat="server">
This is a fairly minor gripe. After all, .NET assumes you’re calling other .NET pages rather than redirecting output to a hideously rubbish system like ITS, and nothing else uses such stupid names for its fields. Still. Leave my HTML alone!