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

  • Thread starter Thread starter clockemail
  • Start date Start date
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?
 
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)
 
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).
 
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.
 
Back
Top