Click here to Skip to main content
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 1:17am
Edited 5-Jun-10 17: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 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 85
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.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