感谢您花时间阅读本文。
我希望执行以下操作,但是它不会在src参数中呈现任何输出:
<asp:ImageButton ID="btnSearch" runat="server" ImageUrl='<%# String.Format("{0}/structure/search_icon.png", MIS.BLL.CommonBLL.Settings.SiteImageURL)%>' CssClass="search_button" />
SiteImageURL是“设置”行中的一列。
非常感谢任何帮助,再次感谢。
答案 0 :(得分:0)
好的,我自己想出来,用一个表达式构建器来生成我自己的方法。
CustomBuilder.vb
Namespace test
Public Class CustomBuilder
Inherits ExpressionBuilder
Public Overrides Function GetCodeExpression(entry As BoundPropertyEntry, parsedData As Object, context As ExpressionBuilderContext) As CodeExpression
Dim type1 As Type = entry.DeclaringType
Dim descriptor1 As PropertyDescriptor = TypeDescriptor.GetProperties(type1)(entry.PropertyInfo.Name)
Dim expressionArray1 As CodeExpression() = New CodeExpression(0) {}
expressionArray1(0) = New CodePrimitiveExpression(entry.Expression.Trim())
Dim temp As [String] = entry.Expression
Return New CodeCastExpression(descriptor1.PropertyType, New CodeMethodInvokeExpression(New CodeTypeReferenceExpression(MyBase.[GetType]()), "GenLink", expressionArray1))
End Function
Public Shared Function GenLink(link As [String]) As [String]
Return String.Format("{0}{1}", CommonBLL.Settings.SiteImageURL, link)
End Function
End Class
End Namespace
Web.config
<compilation debug="true" strict="true" targetFramework="4.0">
<expressionBuilders>
<add expressionPrefix="GenLink" type="test.CustomBuilder"/>
</expressionBuilders>
</compilation>
page
<asp:ImageButton ID="btnSearch" runat="server" ImageUrl="<%$ GenLink:/structure/search_icon.png %>" CssClass="search_button" />
努力享受!希望这有助于其他人...