Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6330603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:54:04+00:00 2026-05-24T17:54:04+00:00

I’ve got some (badly written) legacy code that I have to modify but I’m

  • 0

I’ve got some (badly written) legacy code that I have to modify but I’m having an odd problem with the prefixing of the controls.

The main page has several include files, including cpct_cost.aspx.
Within that included page is a control EquipmentCost:

<INPUT id="EquipmentCost" type="text" name="EquipmentCost" runat="server" size="10" onchange="TotalCost();" class="bk">

Another page references that control in client side javascript:

function TotalCost()
{
    var a = document.CPCT_FORM.cpct_cost_EquipmentCost.value;

This is throwing a client error because when I run the code locally, the control is being named with a $ instead of an _:

<input name="cpct_cost$EquipmentCost" type="text" id="cpct_cost_EquipmentCost" size="10" onchange="TotalCost();" class="bk" />

And as a result, the client side javascript can’t find the element in question.

The legacy code on the server handles this differently – the control name there is processed as:

<input name="cpct_cost:EquipmentCost" id="cpct_cost_EquipmentCost" type="text" size="10" onchange="TotalCost();" class="bk" />

and this is being processed correctly.

I thought at first it might be a local IIS setting, so I compiled my code and deployed it to the dev server, but the behavior was identical to my local execution.

I’m using what are supposed to be the latest source files, I haven’t changed any project settings, so … is there some way I can force the code from my machine to use the : instead of $? Or … what am I missing?

The project is currently on the proposal list to be completely rearchitected, (so please, no suggestions to redesign the app 😉 ) but in the mean time, I have a short term requirement to implement some minor new functionality in this ugly old beast, and I’ve got to get it done ASAP. What’s frustrating is – I haven’t changed these parts of the code at all, but the behavior is changing anyway.

UPDATE

Apparently the naming prefix used in at least .NET 1.1 is somewhat random, because after several builds, while I was trying various ways to work around this, the controls ended up getting the right name. So now I’m just not changing the code, which sucks because I really hate taking this “freeze it while it’s randomly right” approach.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:54:06+00:00Added an answer on May 24, 2026 at 5:54 pm

    You could pass in a reference to the input control as a parameter to the JS function, ie:

    <INPUT id="EquipmentCost" type="text" name="EquipmentCost" runat="server" size="10" onchange="TotalCost(this);" class="bk">
    
    function TotalCost(txtEquipCost) {
    var a = txtEquipCost.value;
    }
    

    Then it doesn’t matter what the id is.

    EDIT:
    If you have more controls, create JS variables on the page, eg:

    var txtEquipCost = document.getElementById('<%= YourControl.ClientID %>');
    var txtOtherCost = document.getElementById('<%= YourOtherControl.ClientID %>');
    

    Then the onChange function call could be TotalCost(txtEquipCost, txtOtherCost)

    EDIT2:
    See this question about ClientId and UniqueId which may be useful:
    C# asp.net Why is there a difference between ClientID and UniqueID?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
i got an object with contents of html markup in it, for example: string
I have a JSP page retrieving data and when single or double quotes are
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.