如何在文本字段中嵌入代码并将其与ASP.NET中的字符串连接?

时间:2012-06-21 16:35:05

标签: asp.net concatenation ascx

在ASP.NET的文本字段中,如何将字符串与变量,方法调用或数据库条目连接起来?

例如:

Text="<some string> + MethodCall()"
Text="<some string> + variable"

1 个答案:

答案 0 :(得分:1)

将字符串与转发器中的数据库条目连接起来:

Text='<%# "Entry: " +  ((<class name storing database values>)Container.DataItem).Entry%>'>

将字符串与转发器外部的数据库条目连接起来:

Text='<%# "Entry: " +  <class name storing database values>.<Get Entry Name Method>%>'>

使用方法连接字符串:

Text='<%# "Entry: " +  <method name>%>'>

该方法应该返回一个字符串。