RESOLVEURL不工作直列 [英] ResolveUrl not working inline
问题描述
我收到错误的低于code在asp.net 4.0
I am getting the error on the below code in asp.net 4.0
<script type="text/javascript" src='<%#=ResolveUrl("~/Scripts/jquery-1.4.1.js")%>'></script>
错误信息:CS1525:无效的前pression术语'='
Error Message: CS1525: Invalid expression term '='
我用这code中的Site.Master头标签
I am using this code in Site.Master in head tag
推荐答案
您不能使用&LT;%#
和&LT;%=
在同一时间。尝试这样的:
You can't use <%#
and <%=
at the same time. Try it like this:
<script type="text/javascript" src='<%= ResolveUrl("~/Scripts/jquery-1.4.1.js")%>'></script>
修改
如果您收到一个错误,指出:
EDIT
If you are getting an error that states:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
当您尝试使用&LT;%= RESOLVEURL(...
,那是因为东西在你的code试图控件添加到你的头控制中的Site.Master如果是这样的情况下,切换脚本标签阅读:
when you try to use <%= ResolveUrl(...
, it is because something in your code is attempting to add controls to your header control in Site.Master. If that is the case, switch the script tag to read:
<script type="text/javascript" src='<%# ResolveUrl("~/Scripts/jquery-1.4.1.js")%>'></script>
和确保你呼吁头标记的的DataBind()
方法,在某些时候(例如,从的Site.Master Page_Load方法):
and make sure you call the DataBind()
method on the header tag at some point (for example, from the Page_Load method for Site.Master):
public partial class SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
Page.Header.DataBind();
}
}
这篇关于RESOLVEURL不工作直列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!