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

  • SEARCH
  • Home
  • 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 7913417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:50:22+00:00 2026-06-03T13:50:22+00:00

I have aspx pages which uses repetitive code. So I put them on a

  • 0

I have aspx pages which uses repetitive code. So I put them on a masterfile and referring that in all other files. I have used the <asp:Content ID> in all other pages where I included master page like,

<asp:Content ID="Step1Content" ContentPlaceHolderID="MainContent" Runat="Server">

My issue is now all the field id’s has a suffix of ContentPlaceHolderID_fieldName and because of this my javascript doesn’t work.

<input id='chkRaces_1' type='checkbox' runat='server' onclick="enableShow50();" /><label for='chkRaces_1'>American Indian or Alaska Native</label><br />

When I debug, it appears like,

<input id="MainContent_chkRaces_1" type="checkbox" onclick="enableShow50(<%# Eval(chkRaces_1.ClientID) %>);" name="ctl00$MainContent$chkRaces_1">

and my Javascript which refrences using id='chkRaces_1' fails. I thought of replacing all the inputs with <asp:ListItem> tags n so, but I get error."type HtmlInputCheckBox" is not compatible with "ListItem". So I got to change the class too which I don’t want to.

What else I can do to achieve the same with minimal change in aspx.

  • 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-06-03T13:50:22+00:00Added an answer on June 3, 2026 at 1:50 pm

    You can use ClientIDMode, but keep in mind that’s only available in .NET 4.0 and above.

    <asp:Label ID="SelectedSport" runat="server" ClientIDMode="Static">
    </asp:Label>
    

    Or in JavaScript:

    var userLabel = document.getElementById('<%=SelectedSport.ClientID%>');
    

    if you are trying to access the control in javascript, then using .ClientID is probably your best bet, as it doesn’t require change in aspx page

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

Sidebar

Related Questions

I have an aspx page that has a @Page directive which points to a
I have a web application which uses URLs that look like this: http://library.example.com/Register.aspx?query=academic&key=586c70bb-5683-419c-aae9-e596af9ab66a (The
Good morning! I have a user login page /Account/Login.aspx which uses a custom I've
I have several aspx pages that can be opened either normally (full screen in
I have written a sample web service, which consist of certain .aspx pages. I
Have a portal which uses forms authentication LoginUrl=Login.aspx DefaultUrl=Default.aspx User credentials are in db...
I have pages within a site containing a control that uses a query string
I have the .aspx page which is already developed in VS 2008 with its
I have an ASPX page which has an iFrame in it the source of
I have an aspx page on which I have 2 static jquery tabs.Upon clicking

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.