Click here to Skip to main content
11,504,892 members (70,730 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript HTML
what i could get information from html in javascript?
for example i want get data from html in textbox of language asp.net c#


<head>

/*i want get information in control by name txtdata */

</head>

<asp:textbox id="txtdata" runat="server" />
Posted 12-Sep-12 10:13am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

try this in Javascript
<html>
<head>
var textBoxvalue = document.getElementById("txtdata");
</head>
<body>
<asp:textbox id="txtdata" runat="server" xmlns:asp="#unknown" />
</body>
</body></html>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is one of main purposes of JavaScript. For example, you can get an input control object using getElementById and then use its property value. In case of text input, it will be the text in the text box. Please see:
http://www.tizag.com/javascriptT/javascript-getelementbyid.php[^],
http://www.w3schools.com/tags/tag_input.asp[^].

Starting from any element, you can also get the whole DOM model of the whole document of its part. Please start here:
http://www.w3schools.com/jsref/default.asp[^],
http://www.w3schools.com/jsref/dom_obj_document.asp[^].

It's more convenient to work with HTML DOM elements using jQuery:
http://en.wikipedia.org/wiki/Jquery[^],
http://jquery.com/[^].

For example, this is the equivalent of getElementById:
inputElement = $("#myTextBox"); // element wrapper, found by the id selector, if the element has the attribute id="myTextBox"
value = inputElement.val(); // use this wrapper
Please see:
http://api.jquery.com/id-selector/[^],
http://api.jquery.com/category/selectors/[^],
http://api.jquery.com/val/[^].

Major DOM navigation is done using traversing methods:
http://api.jquery.com/category/traversing/[^].

If you need to learn jQuery, start here:
http://docs.jquery.com/Tutorials[^],
http://docs.jquery.com/Tutorials:How_jQuery_Works[^].

—SA
  Permalink  
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 F-ES Sitecore 315
1 Sergey Alexandrovich Kryukov 273
2 CHill60 195
3 OriginalGriff 185
4 Richard Deeming 180
0 Sergey Alexandrovich Kryukov 723
1 Peter Leow 490
2 Maciej Los 475
3 DamithSL 470
4 OriginalGriff 437


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 13 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100