[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

asp.net 4 to javascript

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
Galagos1
Asked:
Galagos1
1 Solution
 
Rahul AgarwalTeam LeaderCommented:
Instead of this.document.getElementById("txtDate1").value; use document.getElementById('<%=Test.ClientID%>').value;
0
 
dxdinhCommented:
I think, agarwalrahul meant to use

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

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now