<% string s=LinkButton_ID.Text; %>
<asp:LinkButton ID="LinkButton_ID" runat="server" Text="LinkButton_Text" onclientclick="JscriptFunction(...)">
</asp:LinkButton>
I want to send the “s” as parameter to JscriptFunction. I try JscriptFunction(<% s %>); but doesnt work. Do you have any suggestions? thank you
Try this:
Don’t forget to quote the text value in your JS function call.
EDIT:
I didn’t notice that your call to
JscriptFunctionis inside your server tag. If you don’t have access to jQuery, the easiest way to pass the client-side text of the button is probably this:Here’s an example working on jsFiddle.
You can also pass the client-side ID of the control and manipulate the value using JavaScript. Make sure you have
ClientIDMode="Predictable"orClientIDMode="Static"set on the control if you do it this way.