Click here to Skip to main content
15,920,383 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

I have one javascript file called timepicker.js, which is used for Time Pick and which includes one function called "selectTime". This function have two parameters ctrl1 and ctrl2, this looks like follows

selectTime(ctrl1,ctrl2){}

From aspx page i am passing 2 values of image and textbox. When I am selected time from popup its selecting correct time and showing into textbox but it is giving "Object Required error" on the page. I am passing the textbox value as document.getElementById('<%=txtTime.ClientId%>'). Code is working fine but I want to remove this object required error. The code is looks like follows: -

XML
<script src="timepicker.js" type="text/javascript"></script>

<asp:textbox id="txtTime" runat="server" cssclass="TextBox" value="12:00 pm" width="88px" xmlns:asp="#unknown"></asp:textbox>


<img src="timepicker.gif" id="pick" alt="Pick a Time!" onclick="selectTime(this,document.getElementById('&lt;%=txtTime.ClientId%&gt;'))" />


Is there any other way to pass textbox to function without error?
If I use html input type then its working without any error, but I dont want to use html control. Please it'll be very helpful for me if anyone help me.. Thank you in advance.
Posted
Updated 5-Jun-10 16:45pm
v3

ygulve wrote:
document.getElementById('<%=txtTime.ClientId%>')"


Do a viewsource of your page. Find the ID value of the textbox in it. Lets say it is "ctl00_txtTime" then use:
document.getElementById('ctl00_txtTime') for getting the textbox object.
 
Share this answer
 
when you use client Id in dotnet 3.5 sure was an erorr
txtTime.ID in dot net 3.5 or 3
txtTime.ClientId in dot net 4
but ID not ClientId in dot net for
 
Share this answer
 
check this one

http://www.dreamtheweb.com/2013/12/pass-textbox-value-into-javascript.html
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900