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
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();
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

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

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

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

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…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

580 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