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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:46:33+00:00 2026-05-23T04:46:33+00:00

I would like to get the value of an ASP.NET control from inside of

  • 0

I would like to get the value of an ASP.NET control from inside of a javascript file. I know how to do this when the javascript is on the aspx page, but not when it is in a js file. Example:

<head>
    <script type="text/javascript">
        alert('<%= lbl_test.Text %>'); //alerts the text of the ASP.NET label
    </script>

    <script type="text/javascript" src="Scripts/test.js" /> //alerts "<%= lbl_test.Text" %>
</head>

In this example test.js only has alert('<%= lbl_test.Text %>'); in it.

Is there anyway for me to reproduce the behavior in the first piece of javascript in the js file?

  • 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-23T04:46:34+00:00Added an answer on May 23, 2026 at 4:46 am

    You cannot do it like this you will have to either

    1. pass in the control id from an aspx page (some . net page) that calls into the function in your javascript file

    or

    1. make your script file actually a .net output file. Then you can embed your code. name it for example javscriptwhatever.aspx but set the content type of the file in the code behind to be text/javascript as described here for example
      http://social.msdn.microsoft.com/Forums/en-US/jscript/thread/c706d380-9688-4758-9d7e-9522d59d5855
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have JSF code like: <h:inputText id=from value=#{fromToMBean.fromName}/> I would like to get this
In my ASP.NET Web Forms I would like to get the DataNavigateUrlFields from the
I would like to expose a complex property from a custom ASP.NET user control,
I would like to get the temperature value from Yahoo's weather API. I have
I have a simple ASP.NET Web User Control. It looks like this: <%@ Control
I'm having some problems with implementing javascript controls in my asp.net page. I would
I have an ajax get where I would like to get the selected value
I would like to get to know how to redirect output of some program
I have an ASP.Net MVC 3 page in which I have an Html.TextAreaFor control,
Code language = VB. ASP.NET 4.0 I have a formview control on my page

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.