Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my datalist contains a link buttons.


when i click upon 3rd link i need to get text of that particular link in javascript?
Posted
Comments
Sunasara Imdadhusen 22-May-14 8:41am    
Can you please provide datalist structure here so i will help you to find.

1 solution

On the datalist, wire up the OnClientClick event of the LinkButton in your datalist to a javascript method that can accept the id of the button that you clicked. Then you can display the text of the link button using the innerText property of the link button.

<asp:LinkButton ID="lnkButton" runat="server" Text="OK" OnClientClick='<%# "MyFunction('" + lnkButton.ClientID + "')" %>' />


In your javascript method,
<script type="text/javascript">      
      function MyFunction(id)
      {
        alert(document.getElementById(id).innerText);
      }
</script>


Hope this helps.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900