我在页面中使用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" />
根本没有解释<%=%>,这是什么原因?

解决方案 »

  1.   

    <input type="image" name="img" id="img" src="<%=PathPrefix%>/images/AccounProductCategory_26.gif" />
      

  2.   

    to:net_lover(孟子E章) 
    您的方法自然可以,我想问一下,是不是在web控件中就不能解析<%=%>, <%#%>?
      

  3.   

    当然可以了
    例如下面的代码:
    <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">&nbsp;</TD>
    </TR>
    </TABLE>
      

  4.   

    在web控件中肯定是可以的,要不你在后台代码中写一个函数GetPathPrefix(),然后在前台调用就可以了。
      

  5.   

    服务器控件中还是不能解析<%=%>,我作以下测试:
    <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%>是本地虚拟目录。
      

  6.   

    应该这样:<%#DataBinder.Eval(Container.DataItem,"数据库字段") %>
      

  7.   

    我也分不清什么地方可以用<%#  %>有谁能给总结一下。
      

  8.   

    这是属于数据绑定技术!!网上很多的,可以去找找。在ASP.NET技术揭幕这类书上都有的!!