Name generation issues between 2000 Server and 2003 server

D

Darren

Not sure if this has been covered before.......


I have an issue with an asp.net application running on Windows 2000
server and Windows 2003 server:-

The name generation of html objects (ie input buttons etc) is
different between the 2 environments, even though both are running
..net v2.0.50727


2000 Server generates of the form:-

objSearchList:grdData:_ctl2:_ctl4


but 2003 server generates:-

objSearchList$grdData$ctl02$ctl04


As the working environment is no longer consistent it is no longer
possible to write dynamic javascripts for client-side validation.


We have plenty of customers still working with 2000 server, so
upgrading to 2003 server is not a solution.



Can anyone shed any more light on this?
 
C

Cowboy \(Gregory A. Beamer\)

I wish I had more time to find an URL to help through this. If I understand
the problem correctly, you are writing JavaScript in the page, as
JavaScript, and linking to names you expect to be there. But, they are
generated differently on different versions of windows, so your JavaScript
points to non-existent controls.

You are wondering how you can get past this. One option, that you might have
thought of, is looping through the controls in JavaScript until you find the
right one, but you know that is not a good performance option. So, you want
to know how to get the proper name for the control on both environments.

If I have the above correct ...

You can still write dynamic Javascript (the key here being dynamic) on both
systems with the same code. But, you have to do it in codebehind and either
write the JavaScript out in a literal or emit the JavaScript. The
methodology is writing by asking the conrols what their page name is or what
Postback event they fire, etc.

The best way to get versed in this is to cull through the material on
EmitClientScript etc., along with a thorough review of the control
architecture, paying esp. close attention to the properties common to
controls that allow you to get client side names, etc. for the controls.

There is a lot of information in the controls, but, unfortunately, not a lot
of information about how to use it. As soon as you step out of the tiny box
MS has painted, you have to head out into the wilderness alone. Or, so it
seems.

I will see if I get some time at lunch to get a link for this, or cull
through some code and blog about it.
 
C

cowznofsky

As noted in the other repy, you are coding to the name you expect to be
generated.
But are you sure that the generated name is not available at the time
you're creating your script?
My situation: I had a user control with a list box. I needed the
generated name of the listbox, so I created a property in the code
behind that would get the lstBox.ClientID.
I was able to reference this property in javascript at the top of the
user control, using
window.document.forms[0][<% = lstBoxID %>]
 
D

Darren

Thanks for the replies.

You've both given me some ideas, so I'll re-code a few sections.


Thanks
Darren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top