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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:32:40+00:00 2026-05-25T13:32:40+00:00

I have a variable in javascript: var activeSearchButton = document.getElementById(‘<%=btnSearch.ClientID %>’); I want to

  • 0

I have a variable in javascript:

var activeSearchButton = document.getElementById('<%=btnSearch.ClientID %>');

I want to set it like this:

<asp:TextBox ID="WFTo" runat="server" onchange="activeSearchButton = document.getElementById('<%=btnWFSearch.ClientID %>');"></asp:TextBox>

When I am trying to use the varible in javascript function, it is null. And the source shows:

onchange="activeSearchButton = document.getElementById('&lt;%=btnSearch.ClientID %>');"

I noticed ‘& lt;’ instead of “<“. Is this the reason of my problem? Why does this happen? Or maybe there is another reason?

Thank you very much.

  • 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-25T13:32:41+00:00Added an answer on May 25, 2026 at 1:32 pm

    Just create a function in <script /> section

    function setActiveSearchButton()
    {
        activeSearchButton = document.getElementById('<%=btnSearch.ClientID %>');
    }
    

    and use

    <asp:TextBox ID="WFTo" runat="server" onchange="setActiveSearchButton()"></asp:TextBox>
    

    EDIT:

    As it turns out, you cannot use <%= .. %> for server side controls. You’ll have to resolve to using a regular html input like this

    <input type="text" onchange="setActiveSearchButton('<%= btnSearch.ClientID %>')" />
    

    and

    function setActiveSearchButton(buttonId)
    {
        activeSearchButton = document.getElementById(buttonId);
    }
    

    or leave the <asp:TextBox /> as it is and on Page_Load do

     protected void Page_Load(object sender, EventArgs e)
     {
         WFTo.Attributes.Add("onchange", "setActiveSearchButton('" + btnSearch.ClientID +"')");
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Javascript variable whatToRefresh which is defined in this way: var whatToRefresh
I have javascript string variable with var sttr=We prefer questions that can be answered
I have a long snippet of HTML I want some javascript variable to equal
In Javascript, I have a variable that is set to a block of text
I have problem with variable printing inside javascript. variable htmlString printing not working: document.write(htmlString)
I have a variable in JavaScript: var text = i HATE you[i LOVE you]
I have a javascript variable: var foo='<script type=text/javascript>alert(Hello World);<\/script>' The variable is inserted with
I have a JavaScript variable: var s = <html><head><style>body{a:b;c:d}</style></head><body></body></html>; First, I am extracting the
if I have a javascript variable: var page = <!DOCTYPE HTML PUBLIC \-//W3C//DTD HTML
I have a variable var functionName=giveVote; What I need to do is, I want

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.