In an attempt to access a user control from a JavaScript method and locate the gridview within that control to determine the number of checkboxes checked on the gridview, I encountered an issue. When trying to obtain the ID of the gridview from the usercontrol in the JS method, an error is displayed indicating that the name does not exist in the current context. Below is the code snippet I worked on:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Test.Web.uc"
MasterPageFile="~/SiteMain.Master" EnableEventValidation="false" %>
<%@ Register Src="~/UserControls/UC1.ascx" TagName="uctest" TagPrefix="uc" ID="gv_uc" %>
<script type="text/javascript">
function FindCheckBox()
{
var checkBoxSelector = document.getElementById('<%=gv_uc.("gvgridname").ClientID%>');
}
</script>
The gridview with the name 'gvgridname' belongs to the usercontrol.