Note that there are some explanatory texts on larger screens.

plurals
  1. POunable to get asp:Checkbox ID for jquery in .net c#
    primarykey
    data
    text
    <p>Does anyone know what is it going on here? I have the following code in my aspx file:</p> <pre><code>&lt;tr&gt; &lt;th class="graytext r"&gt;Add Reps to Team:&lt;/th&gt; &lt;td&gt; &lt;asp:GridView ID="grid" runat="server" AutoGenerateColumns="False" DataKeyNames="EmployeeID" DataSourceID="dsEmployees" EnableViewState="false" GridLines="None" CssClass="clGridDirectory"&gt; &lt;Columns&gt; &lt;asp:TemplateField &gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox runat="server" ID="employee_name" Text='&lt;%# Eval("fullname") %&gt;'/&gt; &lt;asp:HiddenField runat="server" ID="employeeidToRep" Value='&lt;%# Eval("employeeid") %&gt;'/&gt; &lt;asp:TextBox runat="server" ID="repID" Text='&lt;%# Eval("rep_id") %&gt;' CssClass="cl_required_for_sale" data-messages="{required:'required'}" /&gt; &lt;asp:RequiredFieldValidator ID="reqvrepID" runat="server" ControlToValidate="repID" Display="Dynamic" EnableClientScript="true" ErrorMessage="required" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;asp:SqlDataSource ID="dsEmployees" runat="server" ConnectionString="&lt;%$ ConnectionStrings:TestConnectionString %&gt;" SelectCommand="app_staff_without_team_select" SelectCommandType="StoredProcedure"&gt; &lt;/asp:SqlDataSource&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>I try to get a alert once the user clicked on the checkbox by using the following code:</p> <pre><code>&lt;script type="text/javascript"&gt; $('#&lt;%= employee_name.ClientID %&gt;').change(function () { alert('bingo') }); &lt;/script&gt; </code></pre> <p>But somehow the error message display when I'm trying to run the page :</p> <pre><code>Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0103: The name 'employee_name' does not exist in the current context Source Error: Line 121: &lt;script type="text/javascript"&gt; Line 122: $('#&lt;%= employee_name.ClientID %&gt;').click(function () { </code></pre> <p>Does anyone know what is it going wrong with my jQuery code? How could I only able to get the checkbox id for the jQuery?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload