肯蒂科评估 ('DocumentType')

Kentico Eval('DocumentType')

这里有什么问题吗?我正在尝试获取没有句号的文档类型。

<script runat="server">
  // we need to remove the . from the DocumentType
  
  public string dt;  
  
  protected override void OnDataBinding(EventArgs e){
    dt = Eval("DocumentType").ToString();
    dt = dt.TrimStart('.');
  }
</script>

<li>
  <p class='title'><a href='<%# GetDocumentUrl() %>' target='_blank' class='type-<%# dt %>' data-name='<%# Eval("FileName") %>'><%# Eval("FileName") %></a></p>
  <p class='description'><%# Eval("FileDescription") %></p>
  <a href='<%# GetDocumentUrl() %>' target='_blank' class='btn btn-chevron type-<%# dt %>' data-name='<%# Eval("FileName") %>'>Download</a>
</li>

TrimStart 只会 trim 个前导字符。你需要 dt.Replace(".", string.Empty).