Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass csharp binding variable to Javascript function
    primarykey
    data
    text
    <p>I want to pass c# binding variable to javascript function. Here is my code:</p> <pre><code>&lt;asp:LinkButton ID="lbID" runat="server" Text="&lt;%#Text%&gt;" OnClientClick="passAccessory('&lt;%#Bind(variable)%&gt;'); "&gt;&lt;/asp:LinkButton&gt; </code></pre> <p>But it always generates an error : "htmlfile: Not implemented". </p> <p>And the code is not intepreted <code>onclick="passAccessory('&amp;lt;%#Bind(variable)%&gt;');"</code></p> <p>Does anyone knows how to solve it ?</p> <p>Thanks. </p> <p><strong>Edit:</strong> I have changed the code to </p> <pre><code>&lt;asp:LinkButton ID="lbID" runat="server" Text="&lt;%#Text%&gt;" OnClientClick="passAccessory('&lt;%# Eval("lblTest.ClientID") %&gt;');"&gt;&lt;/asp:LinkButton&gt; </code></pre> <p>And this is the code it's related to, it uses the <code>lblTest.ClientID</code></p> <p><code>&lt;asp:Label ID="lblTest" runat="server" Text='&lt;%#Bind("reference")%&gt;' /&gt;</code></p> <p>But i received an error: <code>HttpException. Databinding ... does not contain a property with the name lblTest</code>. Is there any wrong with my code. </p> <p><strong>Edit:</strong> These posts gave me a clue. </p> <p><a href="http://www.west-wind.com/Weblog/posts/5364.aspx" rel="nofollow noreferrer">http://www.west-wind.com/Weblog/posts/5364.aspx</a></p> <p><a href="https://stackoverflow.com/questions/831568/i-am-trying-to-learn-how-to-bind-an-ienumerable-linq-collection-to-a-repeater">I am trying to learn how to bind an IEnumerable LINQ collection to a repeater</a></p> <p>Now i have want to use</p> <pre><code>&lt;asp:LinkButton ID="lbTest" runat="server" Text='&lt;%#Text%&gt;' OnClientClick='&lt;%#string.Format("passAccessory(\"{0}\");", Eval("Ref"))%&gt;'&gt;&lt;/asp:LinkButton&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload