Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Assign a Java Script Variable to ASP.Net Texbox

Posted on 2011-09-23
Medium Priority
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 750 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 375 total points
ID: 36593891
if your familiar with query, you can use the following:

var variableName = $("#textbox1").val();
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

LVL 10

Assisted Solution

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

Assisted Solution

sonawanekiran earned 375 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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

688 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