Jeremy
Jeremy

Reputation: 46350

ASP.NET Control's UniqueID delimiter

The UniqueID of a control is delemited with the '$', is it possble that the delimiter can change, and if so, is there a property somewhere that contains the delimiting character?

Upvotes: 4

Views: 1148

Answers (2)

Buggieboy
Buggieboy

Reputation: 4696

I would say that it is dangerous to rely on the exact character used as the delimiter.

I came across some legacy JavaScript code that was passed a UniqueID and parsed it like this:

theform.__EVENTTARGET.value = s.split(":")[0];
theform.__EVENTARGUMENT.value = s.split(":")[1];

Moving to a more recent version of the CLR caused this code to break because, as indicated in this question, the delimiter is now '$', not ':'.

Upvotes: 0

Fredrik Mörk
Fredrik Mörk

Reputation: 158309

Given that there are the protected properties IdSeparator and ClientIDSeparator, I would regard it as subject to change and avoid writing code that make assumptions that a certain character is used as separator. Both those properties are of the type Char, so I would find it unlikely that they would change into using multiple-character separators, but that is just an guess, and also something that I would avoid relying on.

Upvotes: 2

Related Questions