Link to home
Start Free TrialLog in
Avatar of Star79
Star79Flag for United States of America

asked on

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.


ASKER CERTIFIED SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Star79

ASKER

It served the purpose