Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am Having a grid in which there is an link button in side template field.ONClientClick,there is called a js function..
My problem is how do i get the value of clicked LinkButton in js?
Posted
Comments
Monjurul Habib 6-Apr-11 14:46pm    
question not clear. share your code.

1 solution

Try this-

<itemtemplate>
<asp:linkbutton id="btn" text="Your Text" runat="server" onclientclick="LinkClicked(this)" />
</itemtemplate>
<script>
function LinkClicked(lnk)
{
 alert(lnk.innerText);
}
</script>


--Pankaj
 
Share this answer
 
v2
Comments
Rajni from delhi 7-Apr-11 10:18am    
having 2 itemtemplate too.Now,I also want to have this value on above called LinkClicked function?How do i achieve this?
pankajupadhyay29 7-Apr-11 12:14pm    
Add following lines
var row = ctl.parentNode.parentNode;
var tbl = row.parentNode;
var crow = tbl.rows[row.rowIndex + 1];
var gridID = "<%= GridView1.ClientID %>";
var rowID = gridID + '_ctl' + (row.rowIndex > 9 ? row.rowIndex .toString() : '0' + row.rowIndex .toString());
var ctrl = document.getElementById(rowID + "_lblID");
/*lblID is your label(or any other control within grid row) ID*/

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