Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / November 2007

Tip: Looking for answers? Try searching our database.

textbox not recognized in client side

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Claudia Fong - 30 Nov 2007 12:43 GMT
I have a textbox name txtBC but I was trying to check if this textbox is
empty or not.. Jscript gave me this error:

txtBC.value is null or not an object

what should I do?

Cheers!

   Claudi
Dave Bush - 30 Nov 2007 12:54 GMT
Once you've rendered it to your browser, do a view > source and make sure
the ID is still txtBC.  

If you are using master pages, the control is most certainly called ctl00_txtBC
and if you have the control in a user control it will be prefixed with the
name of the user control followed by an underscore.  If you are emitting
the script from your CS or VB code, you can use the ClientId property of
the control to find out what the browser will ultimately see it as.

Dave Bush
http://blog.dmbcllc.com

> I have a textbox name txtBC but I was trying to check if this textbox
> is empty or not.. Jscript gave me this error:
[quoted text clipped - 8 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***
Claudia Fong - 30 Nov 2007 14:32 GMT
view source code shows me this name:

ctl00_ContentPlaceHolder1_ txtBC



Cheers!

   Claudi
Alexey Smirnov - 30 Nov 2007 14:53 GMT
> view source code shows me this name:
>
> ctl00_ContentPlaceHolder1_ txtBC

...because txtBC is a "server-side id" for ASP.NET and in the
Javascript (client-side) code you should use <%=txtBC.ClientID%> to
reference to that element. Look at the code that Mark sent above
Mark Rae [MVP] - 30 Nov 2007 12:59 GMT
>I have a textbox name txtBC but I was trying to check if this textbox is
> empty or not.. Jscript gave me this error:
>
> txtBC.value is null or not an object
>
> what should I do?

if (document.getElementById('<%=txtBC.ClientID%>').value.length == 0)
{
   // do something...
}

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.