if you are working in a page that has a master page, and you want to reference the server controls from JavaScript you must use their ClientID instead of the ID property, so in order to use C# code within JavaScript code, you will have to surround your C# code with the <%= and %>, and this is the example.
var txtBox = document.getElementById(‘<%=txtName.ClientID%>’);
remember this code is available only if your JavaScript code was in an .aspx file not a .js file
I'm a professional components designer, web developer, UX engineer and 3d designer as well, I'm 4 years experienced .net software engineer and 7 years experienced 3d designer using 3D Max. I'm very interested in RIA technologies, prototyping and UX engineering.
Ahmed Said
Senior .Net Software Engineer