Click here to Skip to main content
13,043,654 members (52,431 online)
Rate this:
Please Sign up or sign in to vote.
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


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: -

<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 27-May-10 0:17am
Updated 5-Jun-10 16:45pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

ygulve wrote:

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

check this one

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 6 Dec 2013
Copyright © CodeProject, 1999-2017
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