inline code not compiling inside a OnClientClick

Viewed 44

I trying this code inside a asp:hyppelink inside a repeater.

OnClientClick='openURL( "<%# Eval("UrlPagamento")%>", "<%# Eval("IdPedido")%>")'>

and the outcome after compilling is this:

<a class="btnPequeno" onclientclick="openURL( &quot;<%# Eval(&quot;UrlPagamento&quot;)%>&quot;, &quot;<%# Eval(&quot;IdPedido&quot;)%>&quot;)" href="#">Pagar</a>

I Tried to change the symbols " and ' but then I just got a syntax error.

Any ideia how to solve it?

1 Answers

You have to bind all the string elements inside the databinding expression and escape the ' with &#39;

OnClientClick='<%# "openURL(&#39;" + Eval("UrlPagamento") + "&#39;, &#39;" + Eval("IdPedido") + "&#39;)" %>'
Related