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 8124771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:34:27+00:00 2026-06-06T06:34:27+00:00

I am running some java script with a couple html controls. Everything works fine.

  • 0

I am running some java script with a couple html controls. Everything works fine.

Except when I add the runat = ” server” attribute to the html control, so I can access it in the code behind, the java script function does not work. Is this a common thing? Is there a work around for using a runat = ” server” attribute with java script?

Or how can I access my Html control in the code behind WITHOUT using the run at server attribute?

Confused.

  • 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-06T06:34:29+00:00Added an answer on June 6, 2026 at 6:34 am

    This is most likely occuring because your markup looks something like this:

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <div runat="server" id="myDiv">
        </div>
    </asp:Content>
    

    i.e. You’re using a MasterPage or something else that acts as an INamingContainer. This results in the ID that’s written out in the markup looking something like this:

    <div>
        <div id="ContentPlaceHolder1_myDiv">
        </div>
    </div>
    

    If you’re using asp.net 4 you can change your markup for myDiv by adding clientidmode="Static" and you’ll then get:

    <div>
        <div id="myDiv">
        </div>
    </div>
    

    Meaning your javascript will work again. If you’re using earlier versions of asp.net then you’ll need to do as SHAKKIR SHABBIR suggested and use <%=myDiv.ClientId%> to reference the element in your javascript so you get the “renamed” version of the ID that asp.net produces.

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

Sidebar

Related Questions

I'm having some trouble running gnuplot processes from Java. I'm creating a gnuplot script
We have a system that has some Bash scripts running besides Java code. Since
Trying to truncate some code here and running into a problem: <script type=text/javascript> $(function()
I have some Java code that is throwing out of memory exceptions after running
I have some enterprise apps running on Java 1.4. They mostly invoke Stored Procedures
I have a java script code which will set some values in a form
I have a Java program performing some large analysis tasks, running through a loop
I need to do some scripts in java script. I am working on it
I'm running a java app which creates a visual display of some of the
I am running Selenium Server. I'm also launching an automated test script that I

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.