Assign a Java Script Variable to ASP.Net Texbox

Posted on 2011-09-23
Last Modified: 2012-05-12
How can I declare a variable in Java Script that is linked to ASP.Net Textbox.

For example

 var VariableName = textbox1.text ??

Question by:jeffreyjseaman
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 10

Accepted Solution

Chad Smith earned 250 total points
ID: 36590856
var variable = document.getElementById("V_DLEAVE").value

Author Comment

ID: 36592583
What is V_DLEAVE ?
LVL 14

Assisted Solution

binaryevo earned 125 total points
ID: 36593891
if your familiar with query, you can use the following:

var variableName = $("#textbox1").val();
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

LVL 10

Assisted Solution

by:Chad Smith
Chad Smith earned 250 total points
ID: 36593966
Sorry V_DLEAVE should be replaced by the ID of your textbox
LVL 17

Assisted Solution

sonawanekiran earned 125 total points
ID: 36595111
Use jquery. U have more adv over javascript. U can assign value to javascript variable in couple of ways:
1) var ur_var=$("#<%=textbox1.ClientID%>").val();


2) assign class to textbox e.g. CssClass="txtclass" & ten use below jquery

var ur_var=$(".txtclass").val();

Author Comment

ID: 36595276
Ok thanks i will try that. I would prefer Jquery

Author Closing Comment

ID: 37250862
partilly worked

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash ( has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question