explanation of differences in ASP.NET Repeater unique name format string
Can anyone explain reasons why the name property of a Repeater control's child con开发者_StackOverflow中文版trols would be generated differently in an ASP.NET application when it is deployed on different IIS servers?
One some IIS servers the Name is generated using the format:
String.Format("{0}:_ctl{1:00}:{2}", RepeaterControlID, itemIndex, ChildControlID);
e.g.
<input name="Mntc_Software_List:_ctl1:id" id="Mntc_Software_List__ctl1_id" type="hidden" value="1772" />
and on other IIS servers the format is:
String.Format("{0}$ctl{1}${2}", RepeaterControlID, itemIndex, ChildControlID);
e.g.
<input name="Mntc_Software_List$ctl01$id" type="hidden" id="Mntc_Software_List_ctl01_id" value="1772" />
The difference between your two names is that one uses a '$' separator and the other a ':' separator. Using Lutz reflector on the Control class reveals that this is controlled by a property 'EnableLegacyRendering', which is something to do with XHTML 1.0–conforming control rendering (MSDN).
Google for EnableLegacyRendering for more info.
Actually, i believe one is the name and one is the ID. I forget which is which, but the rules for names and ID's are different.
If you're certain they're both Name's, then are you sure you have the same version of .NET both servers? Older versions may geneate their names differently.
精彩评论