The error occurred because the server control is not yet rendered, while the JavaScript code is executed. Go through below solutions:
Solution 1: Put your javascript code to bottom bottom of your page. It means append javascript code after form tag.
Solution 2: It looks like "<%=" present in .aspx file. So try to use <%# instead of <%=
And also add following code in page_load()
protected void Page_Load(object sender, EventArgs e)
{
Page.Header.DataBind();
}