如何查找在clienside中单击时在datalist中的linkbutton的文本 [英] How to find text of a linkbutton which is in datalist when it is clicked in clienside

查看:77
本文介绍了如何查找在clienside中单击时在datalist中的linkbutton的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的datalist包含一个链接按钮。





当我点击第3个链接时我需要在javascript中获取该特定链接的文本?

my datalist contains a link buttons.


when i click upon 3rd link i need to get text of that particular link in javascript?

推荐答案

在数据列表中,将数据列表中LinkBut​​ton的OnClientClick事件连接到一个javascript方法,该方法可以接受您单击的按钮的ID。然后,您可以使用链接按钮的innerText属性显示链接按钮的文本。



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





在您的javascript方法中,



In your javascript method,

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





希望这有帮助。



Hope this helps.


这篇关于如何查找在clienside中单击时在datalist中的linkbutton的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆