Steelymar:
use this :
<asp:LinkButton ID="LinkButton2" runat="server" OnClientClick="javascript:return addtab(this);" CausesValidation="false"
CommandName="name" Text='<%# Eval("[ name]") %>' CommandArgument='<%# Eval("[Id]") %>'></asp:LinkButton>
function addtab(sender){
alert(sender.value);
}
Sorry but there is no "value" property in that control.
That is because this: var b = document.getElementById("LinkButton2") will not work for controls in a Grid since the ID becomes something like: "GridView1_ctl02_LinkButton2" when the Grid is rendered.
The easies way to fix that is by using the this pointer:
<asp:LinkButton ID="LinkButton2" runat="server" OnClientClick="javascript:return addtab(this);" ...
Change your JavaScript accordingly:
<script type="text/javascript">
<!--
function addtab(linkButtonRef)
{
//alert('begin');
var tabctrl1 = window.parent.igtab_getTabById('Tab2');
tabctrl1.Tabs[2].setEnabled(true);
tabctrl1.Tabs[2].setVisible(true);
// var b = document.getElementById('LinkButton2');
alert(linkButtonRef.innerText); //this not working
//alert('end');
}
// -->
</script>
Also note that you are using the innerText property wich will only work in Internet Explorer.
var elementValue = '';
if ( elementRef.textContent )
{
// Firefox...
elementValue = elementRef.textContent;
}
else if ( elementRef.innerText )
{
// IE...
elementValue = elementRef.innerText;
}
else
{
// Default...
elementValue = elementRef.innerHTML;
var regExp = /<\/?[^>]+>/gi;
elementValue = elementValue.replace(regExp, '');
}
NC...