Click here to Skip to main content
11,715,491 members (86,201 online)
Rate this: bad
good
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

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

<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
Edited 5-Jun-10 16:45pm
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

Solution 3

check this one

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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 518
1 Richard MacCutchan 300
2 Maciej Los 259
3 ManasKumarM 155
4 Frankie-C 125
0 Sergey Alexandrovich Kryukov 785
1 CHill60 415
2 Richard MacCutchan 405
3 Maciej Los 389
4 OriginalGriff 320


Advertise | Privacy | Mobile
Web03 | 2.8.150901.1 | Last Updated 6 Dec 2013
Copyright © CodeProject, 1999-2015
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