Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
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 1:17am
Edited 5-Jun-10 17: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
0 OriginalGriff 240
1 Kamal Rocks 184
2 CPallini 155
3 PIEBALDconsult 150
4 BillWoodruff 148
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180

Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 6 Dec 2013
Copyright © CodeProject, 1999-2014
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