alert(document.getElementByID('<%=txtDemo.ClientID %>'));
in fact you can do a lot more than get your control client ID, you can do code with in the <% %> tags. These are called server tags, the code written within these tags is run on the server and the corresponding values are placed. For ex. if you want to get the username in stored in the session,
you can use
var userName = '<%= Session["userName"].ToString() %>';
the <%= %> defines the assignment, tells the server that the values generated should be placed at the same location.
<%# %> this tag is used for binding data in in repeater, datagrid etc...