Replacing <%= Control.ClientID %> in external javascript

I have an aspx with a control on it, lets call it txtDate, and I have an
external javascript file.

In the external javascript file, I have

var strContName = "document.getElementById('<%= txtDate.ClientID%>')";

which would work fine if the javascript was in the .aspx file, but when
adding the external javascript file via  
  System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<script type='text/javascript' language='JavaScript' src='DVLP.js'></script>");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "OnLoad", sb.ToString());
the txtDate.ClientID does not get replaced with the client id.

Is there a way to do this.
Thanks all.

Who is Participating?
David H.H.LeeCommented:
Hi Star79,
The easiest way is pass the control ID as parameter inside the defined function. This could solve your problem.
function yourfunction(strControlID){
 //bla bla bla

//call in your page
Star79Author Commented:
It served the purpose
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.