Change javascript src attribute from ASP.net Code Behind

asp.net, c#, html, javascript

Solution

You can't access the `src` attribute like that. HTML attributes are accessible via the `.Attributes` collection:

srcSurvey.Attributes["src"] = "my/directory/file.js";

Problem

I am trying to change JavaScript src from a code behind file. ``` <script type="text/javascript" runat="server" id="srcSurvey" language="JavaScript" src="mypage.asp?p=2"></script> ``` When I am trying to access the object properties from the code behind file, no src option is available, do I need to put the src file at some other property?

Original source