defn [Name Mangling wikipedia]: In software compiler engineering, name mangling (more properly called name decoration, although this term is less commonly used) is a technique used to solve various problems caused by the need to resolve unique names for programming entities in many modern programming languages.
you can do it simply by document.getElementByID..but you will get stuck when your control lies under Master Page…if you keep the same function which you have used for simple page[without Master page] IE Will say “Object required”. Because in your simple page the ID of control will be same…and if you add Master Page than id will be something like ctl00_ContentPlaceHolder1_txtName.. let’s see it by example
Suppose you have one control in simple ASP.NET Page and has ID txtName.
Now if you put it in MasterPage which has ContentPlaceHolder and had ID= ContentPlaceHolder1.
so now your ID= ctl00_ContentPlaceHolder1_txtName So the pattern for generating name i like :
ctl00_<ContainerID>_<CONTROL ID> for example ID = ctl00_ContentPlaceHolder1_txtName
Hope you are clear now.. so how you will find you control by this ID????
and Now you have to do:
document.getElementById(“<%= txtName.ClientID %>”).value
Looks cool na??
Hope you have enjoyed this article.
Happy Java scripting.
UPDATED 19-2-2008 VER 1.1
I have tried this with my page which has .js file located under different folder and i have linked it with page using tag.
But it was not working because Visual studio doesn’t Parse this file and ClientID will not work.
So, Conclusion is that you can’t use ClientID with different .js file