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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:32:41+00:00 2026-05-29T19:32:41+00:00

I know this is a very common problem. I was trying to get a

  • 0

I know this is a very common problem. I was trying to get a “enter key” event to invoke a click on a certain button on the page through javascript. However, I can’t for the life of me fetch a single element by its id or name from my asp.net page.

It is my understanding that this issue is related to where the javascript is located and whether the elements have been rendered by the time the javascript is loaded or something of that nature?

Every time I attempt to use var x = document.getElementById('btn_AddAdmin') I end up with a null value.

My asp.net page has SiteMaster page that it inherits from. I have included a trimmed down version of my asp.net page and the SiteMaster page.

ASP.NET Page:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" 
     AutoEventWireup="true" CodeBehind="Admin.aspx.cs" Inherits="HERMES.Admin" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<input type="text" id="txt_AddAdmin" runat="server" onkeypress="Populate()" />

Master Page:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" 
         Inherits="HERMES.SiteMaster" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
    <title></title>
    <link href="./Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form runat="server">
</form>
</body>

Sorry for the formatting, I seem to be doing something wrong…

I have attempted placing the javascript in many different locations — anywhere from the sitemaster page to the top and bottom of my asp.net page. No luck either way.

  • 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-29T19:32:44+00:00Added an answer on May 29, 2026 at 7:32 pm
    var x = document.getElementById('<%= btn_AddAdmin.ClientID %>');
    

    If your button is a Server Control it prepends a naming scheme to the input button so it can be bound back to the appropriate server control during postback. Thus the need to use the ClientID property to retrieve the “rendered id”.

    To learn more visit:

    • http://www.asp.net/web-forms/overview/client-script,-jquery,-and-ajax
    • http://www.asp.net/

    Google it with Bing:

    • clientid
    • aspnet webforms client side programming
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this is very common problem and I have gone through almost
I know this is the most common problem in the history of programming but
I know this is very common question but I am really stuck in this
I'm having a very common problem that I don't know how to fix for
I know this is a very common question, but I tried googling and got
I know this is very evil, but is it possible to add an object
I know this is very similar to a few other questions, but I can't
I know this maybe a very basic question but I'm having a bit of
I know this is a very broadly scoped question, but what do I need
I know this might be very easy to some,, I have a simple string

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.