Solved

asp.net 4 to javascript

Posted on 2011-03-04
2
281 Views
Last Modified: 2012-05-11
How do you read in a value from a asp.net text box in javascript.  I am not using a form.
var dateValue = new Date();
dateValue = this.document.getElementById("txtDate1").value;
reading it from this text box.
<asp:TextBox
     ID="txtDate1"
     runat="server"/>
I get this error when I run it
Microsoft JScript runtime error: Object required
0
Comment
Question by:Galagos1
2 Comments
 
LVL 13

Accepted Solution

by:
agarwalrahul earned 125 total points
ID: 35041559
Instead of this.document.getElementById("txtDate1").value; use document.getElementById('<%=Test.ClientID%>').value;
0
 
LVL 7

Expert Comment

by:dxdinh
ID: 35041780
I think, agarwalrahul meant to use

dateValue = document.getElementById('<%=txtDate1.ClientID%>').value
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

791 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