Inline code not compiling inside an OnClientClick event

106 Views Asked by At

I'm 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 idea how to solve it?

1

There are 1 best solutions below

0
On BEST ANSWER

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