I want to pass c# binding variable to javascript function. Here is my code:
<asp:LinkButton ID="lbID" runat="server" Text="<%#Text%>" OnClientClick="passAccessory('<%#Bind(variable)%>'); "></asp:LinkButton>
But it always generates an error : “htmlfile: Not implemented”.
And the code is not intepreted onclick="passAccessory('<%#Bind(variable)%>');"
Does anyone knows how to solve it ?
Thanks.
Edit: I have changed the code to
<asp:LinkButton ID="lbID" runat="server" Text="<%#Text%>" OnClientClick="passAccessory('<%# Eval("lblTest.ClientID") %>');"></asp:LinkButton>
And this is the code it’s related to, it uses the lblTest.ClientID
<asp:Label ID="lblTest" runat="server" Text='<%#Bind("reference")%>' />
But i received an error: HttpException. Databinding ... does not contain a property with the name lblTest. Is there any wrong with my code.
Edit: These posts gave me a clue.
http://www.west-wind.com/Weblog/posts/5364.aspx
I am trying to learn how to bind an IEnumerable LINQ collection to a repeater
Now i have want to use
<asp:LinkButton ID="lbTest" runat="server" Text='<%#Text%>' OnClientClick='<%#string.Format("passAccessory(\"{0}\");", Eval("Ref"))%>'></asp:LinkButton>
I didn’t do ASP.NET webforms for along time, but I believe it should be like this:
OnClientClick="<%# string.Format("passAccessory('{0}');", Container.DataItem("variable")) %>"