im using asp.net with c#.
I have a gridview and there is a TemplateField column. Inside the TemplateField column there is a EditItemTemplate, and inside EditItemTemplate the is a linkbutton(LinkButton1).
Im trying to do a getelementbyid on the linkbutton from a javascript function:
document.getElementById("<%= LinkButton1.ClientID %>").disabled = true;
But when compiling, I get the error: “The LinkButton1” does not exist on the current context.
The aspx gridview code:
<asp:GridView ID="GridView1" runat="server" Height="157px" Width="814px"
CellPadding="4" ForeColor="#333333" GridLines="None"
OnRowEditing="GridView1_RowEditing"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowUpdating="GridView1_RowUpdating" AutoGenerateColumns="False"
OnRowDataBound="GridView1_RowDataBound"
onrowdeleting="GridView1_RowDeleting" Font-Size="Medium"
AllowPaging="True" onpageindexchanged="GridView1_PageIndexChanged" onpageindexchanging="GridView1_PageIndexChanging" >
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
Text="Actualizar" ValidationGroup="upd_validation"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancelar"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Edit"
Text="Editar"></asp:LinkButton>
<asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False" CommandName="Delete"
Text="Eliminar" CommandArgument='<%# Container.DataItemIndex %>' onclientClick="return ConfirmDelete()"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
How can I solve this?
Thanks.
U can add some dummy css class to the LinkButton (example “disableLink”), and then using Jquery, u can easily achieve it using the below code