1

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") %>);">
1
  • You will need to edit your question, it doesn't appear to be displaying correctly Commented Aug 16, 2011 at 10:37

2 Answers 2

2
onclick='<%#"select(this, "+Eval("ID").ToString()+")" %>'
Sign up to request clarification or add additional context in comments.

Comments

2

Another option to make this a bit neater:

onclick='<%# Eval("ID","select(this,{0})") %>'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.