pointeman
asked on
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)?
Q. Is there another way to code this in ASP because it gives me a Code Block error residing in the HEAD of our Master Page?
<script type="text/javascript" src="<%= Page.ResolveClientUrl("/sc
Error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)?
Hi
If you place a placeholder in the head section like this
Then in the Page_Load section (or where ever you want it to be) add this
Jawa29
If you place a placeholder in the head section like this
<head>
<asp:PlaceHolder ID="MyScriptPH" runat="server" />
</head>
Then in the Page_Load section (or where ever you want it to be) add this
Dim objPH As New PlaceHolder()
objPH = Master.FindControl("MyScriptPH")
Dim objScript As New HtmlGenericControl("script")
objScript.Attributes.Add("type", "text/javascript")
objScript.Attributes.Add("src", Page.ResolveClientURL("/scripts/JScript.js"))
objPH.Controls.Add(objScript)
Jawa29
ASKER
crisco96:
will this work? <script language="javascript" type="text/javascript" src="scripts/JScript.js" />
Error: Too many characters in character literal
ScriptReference.Text = "<script type='text/javascript' src=' + Page.ResolveClientUrl("/scriptz/JScript.js") "'></script>";
will this work? <script language="javascript" type="text/javascript" src="scripts/JScript.js" />
Error: Too many characters in character literal
ScriptReference.Text = "<script type='text/javascript' src=' + Page.ResolveClientUrl("/scriptz/JScript.js") "'></script>";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very good, thanks...
Q.will this work? <script language="javascript" type="text/javascript" src="scripts/JScript.js" />
I found is else where on the web.
Q.will this work? <script language="javascript" type="text/javascript" src="scripts/JScript.js" />
I found is else where on the web.
Open in new window
with
Open in new window
Then in your code behind do:
Open in new window