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