Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

repeater controls renamed to "_ctl00_"!

Status
Not open for further replies.

ChainsawJoe

Programmer
Dec 5, 2000
154
GB
Hi all,

Can anyone tell me why, having upgraded to .net 2.0.50727, the controls within a repeater on a test server (also running same version of .net) have changed from
Code:
ctlReturnBuilder_rptReceiptItems__ctl0_drpdwnVoidReasons
to
Code:
ctlReturnBuilder_rptReceiptItems__ctl00_drpdwnVoidReasons
(two "0"s)?

Within the project I'm working on there is a lot of javascript that relies on knowing the ids of the controls within a repeater, and I know about clientID but it isn't applicable to our situation unfortunately - the javascript takes the value selected in a drop down and slaps the selected value into a hidden text field in the same repeateritem, hence making use of clientId tricky.

As far as I can see there is no difference in the set up between my local pc and the test server's .net installation, and this is really stumping me.

Can anyone point me in the right direction please?!

Many thanks!
 
I can't say why it's happened (and I don't particularly fancy going through ASP.NET's naming convention with reflector) but at least it highlights the robustness of your code. Rather than relying on the id, which could change if you alter the structure of your page, you need to use a method which will take this into account.

In javascript you can pass "this" as a parameter which will send the object in question which may be a more appropriate means of retrieving the value. I'd ask for more help in the javascript forum (forum216) if you need assistance with writing client-side script.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Thanks for your suggestions, but we're already passing the "this" and the index of the current repeateritem to a js function in order to get a sibling repeateritem control and set that control's value.

I realise this code needs revisiting, but this is not a viable option at the moment - we just need to find out why the id decided to change. (It's not a client-side area, just intranet)

If anyone knows why this might've happened, your help would be very much appreciated!

Many thanks,

CJ
 
we just need to find out why the id decided to change.
Will that really help? Surely if you manage to look through the .NET code and find out what sets these id's to the new format, you will still be in the same predicament? You can't change the id's via code (well, you can but then it will break the server-side code) so isn't it best to just fix the client-side code so that it is more robust and will cope with these type of changes?


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Hi,

I totally see your point, but I don't like that something has intrinsically changed in the rendering of the controls.

This intranet project is quite old and relies heavily on the use of javascript.

We *will* update the code, but firstly need to get the *existing* version working on the .net 2 platform.

I don't want to go through loads of pages and update the javascript when I plan on doing the whole project in a different manner in the near future. I'd like to just find out why one instance of a .net 2 project renders controls differently to the same project on a different instance.

Any pointers on why this might happen would be extermely helpful.

Many thanks,

CJ
 
OK, let's go back to comparing the two web servers then. What versions of the framework to they both have installed? Have you check the IIS properties for both websites (specifically the ASP.NET tab) to see if both sites are set to use the same version. Have you tried running "aspnet_regiis -i" to reinstall the framework?


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Many thanks for your suggestions!

On both boxes:
ASP.NET 2.0.50727

Checking all tabs having clicked "edit config" in the asp.net tab of IIS on both machines, the only differences are the values of a few appsettings in the web.config to point to different databases (dev & test).

I've run aspnet_regiis -i from within the v2.0.50727 dir on both machines and still no change.

Thank you for your suggestions Mark, and if anyone else has any thoughts please let me know - any pointers will be greatly appreciated.

 
If anyone's interested, to "fix" both this and the fact that .net2 replaces ":" with "$" in server control "name" attributes, check that there's the key
Code:
<xhtmlConformance mode="Legacy"/>
in the system.web area of the web.config.

This reverted the rendering for me, and yes, I know it's a bad way to do things, but in order to rewrite the app bit by bit, we needed the thing to work as a whole initially.

Maybe in the future we'll be able to remove that Legacy entry - fingers crossed.

Thanks for your suggestions Mark - you are indeed correct that the code we're using is dependant on some bad practise; hopefully this can be recified later on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top