asp.net repeater item template <li> 元素,如何通过函数设置任何属性?

asp.net repeater item template <li> element, how to set any attribute through a function?

<asp:Repeater runat="server" ID="rptStockListings">
 <ItemTemplate>
    <li rank=$.getRank(<%# Container.ItemIndex + 1 %>,           <%#DataBinder.Eval(Container.DataItem,"IsPremium") %>))

这不会执行我在单独的 JS 文件中的 getRank(index, isPremium) 函数,return给我一个字符串。

输出如下: getRank(1,true) 而不是函数的 return 值。

如何从这里调用函数?我需要调用它,因为我必须使用该 js 文件中定义的全局变量。

您可以从中继器内部调用代码隐藏函数。 (如果您可以使用代码隐藏,请搜索此内容。)

示例:How to call a function inside a ItemTemplate at a ListView Control

我有另一个例子,但我现在找不到了。 hth.