Monday, 26 August 2013

Getting ClientID of asp controls within a asp:GridView's ITemTemplate

Getting ClientID of asp controls within a asp:GridView's ITemTemplate

I am having
<asp:GridView ID="gdvResxKeyValue" runat="server" Width="100%"
AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField >
<ItemTemplate>
<asp:Image ID="imgEditResxValue" CssClass="sfEdit"
onclick="ClickImage(this)" runat="server"
ImageUrl="~/Administrator/imgedit.png" />
<asp:Button ID="hiddenButton" runat="server"
OnClick="hiddenButton_Click" style="display:none"></asp:Button>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
and now need to take clientID of asp:Button and tried taking as,
$(document).ready(function () {
function ClickImage(imageControl) {
document.getElementById('<%=hiddenButton.ClientID%>').click();
}
}
But this throws an error while building as,

Is there any way to take the ClientID?
Thank you.

No comments:

Post a Comment