Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change javascript src attribute from ASP.net Code Behind

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?

enter image description here

like image 630
Laziale Avatar asked Aug 01 '26 04:08

Laziale


1 Answers

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

srcSurvey.Attributes["src"] = "my/directory/file.js";
like image 165
Jason Avatar answered Aug 03 '26 17:08

Jason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!