Visual Studio .Net 2003 Project running in IIS with ASP.NET 2.0

C

clockemail

I have a VB ASP.NET project that was compiled using Visual Studio
2003, and which works perfectly when using ASP.NET 1.1 in IIS.
However, if I run IIS with ASP.NET 2.0, controls within repeaters
become relabeled, which leads to bugs in my JavaScript code. For
example, a textbox that is labeled as rptDiag__ctl1_txtVersion in the
source code when ASP.NET 1.1 is used, appears as
rptDiag_ctl01_txtVersion when ASP.NET 2.0 is used. Would I be right to
assume that I should accept that ASP.NET 2.0 should not be used with
Visual Studio 2003 projects?
 
B

bruce barker

no. its a coding bug. controls are dynamically named, so you should
never view source to get the name, but use the ClientID on the server.

<script>
var myControl = document.getElementById('<%=myControl.ClientID%>');
</script>

-- bruce (sqlwork.com)
 
C

clockemail

I am referring to the controls as I have entered them in my VB code,
which works fine when the project is run under ASP 1.1 in IIS, but
when run under ASP 2.0 in IIS, bugs occur in the JavaScript because
the controls have been relabeled (by ASP 2.0, not by me).
 
T

Teemu Keiski

As Bruce said, you shouldn't refer them, since ASP.NEt does renaming of
control ids based on how they are contained in naming containers etc. The
reliable way is to use ClientID, it is meant for client-script scenarios.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top