Search code examples
asp.netwebformsrepeater

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") %>))

This doesn't execute the getRank(index, isPremium) function that i have in separate JS file which returns me a string.

And the output looks like: getRank(1,true) instead of return value of the function.

How can i call function from here? I need to call it since i have to use global variable defined in that js file.


Solution

  • you can call code-behind functions from inside a repeater. (search for this if you can use code-behind.)

    sample: How to call a function inside a ItemTemplate at a ListView Control

    i had another example but i can't find it now. hth.