我在页面中使用ImageButton指定图片源时如下:
<asp:ImageButton
ID="img"
ImageUrl="<%=PathPrefix%>/images/AccounProductCategory_26.gif"
Runat="server" />
运行后查看源文件时显示为:
<input type="image" name="img" id="img"
src="<%=PathPrefix%>/images/AccounProductCategory_26.gif" />
根本没有解释<%=%>,这是什么原因?
<asp:ImageButton
ID="img"
ImageUrl="<%=PathPrefix%>/images/AccounProductCategory_26.gif"
Runat="server" />
运行后查看源文件时显示为:
<input type="image" name="img" id="img"
src="<%=PathPrefix%>/images/AccounProductCategory_26.gif" />
根本没有解释<%=%>,这是什么原因?
您的方法自然可以,我想问一下,是不是在web控件中就不能解析<%=%>, <%#%>?
例如下面的代码:
<TABLE cellSpacing="0" cellPadding="0" width="135" align="center">
<TR>
<TD height="16"></TD>
</TR>
<%
string ConnClassLX=Request.Cookies["Connection"].Value.ToString();
if (ConnClassLX=="LXLGB")
{
%>
<TR>
<TD height="24">
<A href="../Reportforms/ReportMainLX.aspx" target="right">离休干部统计报表</A>
</TD>
</TR>
<%
}
%>
<%
string ConnClassTX=Request.Cookies["Connection"].Value.ToString();
if (ConnClassTX=="TXLGB")
{
%>
<TR>
<TD height="24"><A href="../ReportformsEXT/ReportMainTX.aspx" target="right">退休干部统计报表</A>
</TD>
</TR>
<%
}
%>
<TR>
</TR>
<TR>
<TD height="16"> </TD>
</TR>
</TABLE>
<asp:HyperLink
id=HyperLink1
runat="server"
NavigateUrl="<%=PathPrefix%>/index.aspx">test1</asp:HyperLink>
<div><a href="<%=PathPrefix%>/index.aspx">test2</a></div>
test1的链接地址是:http://localhost/<%=PathPrefix%>/index.aspx
test2的链接地址是:http://localhost/index.aspx
其中<%=PathPrefix%>是本地虚拟目录。