Reputation: 3660
is it possible to use inline c#
code (i.e. <%# someFunction(someParameter) %>
) in serverside html tags? The reason I ask is that I do this sort of thing with a regular <div>
tag and it works well, but as soon as I add the following code it passes the code through with the output html to the client.
Here's my original div tag:
<div class="invoiceUnselected" onclick='select(this,<%# Eval("ID") %>);' >
which passes through:
<div class="invoiceSelected" onclick="select(this,271856);">
and the new:
<div id="divInvoiceHeader" runat="server" class="invoiceUnselected"
onclick='select(this,<%# Eval("ID") %>);' >
passes through
<div id="ctl00_bodyCPH_accRenewals_Pane_0_header_divInvoiceHeader"
class="invoiceUnselected" onclick="select(this,<%# Eval("ID") %>);">
Upvotes: 1
Views: 3418
Reputation: 10219
Another option to make this a bit neater:
onclick='<%# Eval("ID","select(this,{0})") %>'
Upvotes: 2
Reputation: 1321
onclick='<%#"select(this, "+Eval("ID").ToString()+")" %>'
Upvotes: 2