Reputation: 3406
I have this fields, with visible = "false" I can access it via the cs page in backend, but how can I acess this control with jquery? I little code might help..
<tr>
<td class="TDCaption" style="text-align: left">
<asp:Label ID="lblMsg" runat="server" EnableViewState="False" ForeColor="#CC0000"></asp:Label>
<div class="DivStyleWithScroll" style="width: 100%; overflow: scroll; height: 250px;">
<asp:GridView ID="grdReport" runat="server" AutoGenerateColumns="False"
DataKeyNames="CustCode" ShowFooter="True" EmptyDataText="No record found"
PageSize="50" CssClass="mGrid" onrowdatabound="grdReport_RowDataBound">
<Columns>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label ID="lblCustCodes" runat="server" Text='<%# Eval("CustCode") %>' CssClass="grdCustName"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<%--other columns--%>
The jquery is
$('#<%=btnCompare.ClientID%>').click(function () {
if ($(':checkbox:checked').size() == 0) {
}
else {
custList = $(':checkbox:checked').map(function () { return $(this).closest('tr').find('.grdCustName').text() }).get();
alert(custList);
}
});
Upvotes: 1
Views: 6931
Reputation: 7451
Label.ForeColor = System.Drawing.Color.Transparent
in code behind
then set the Label Visible
to true
Upvotes: 0
Reputation: 3681
If Visible is false, then the control did not go down to the client, so you cannot directly access it from javascript/jquery: it simply isn't there. you can put the control's value in some hidden field
and then can access it. as they are never visible in frontend. Hiddenfields
are visible only in HTML
source.
Upvotes: 0
Reputation: 19953
I believe setting .Visible = false
will stop the control from being rendered into the HTML, so the jQuery will simple not be able tofind it.
Instead, for code-behind, try using...
ctrl.Style("display") = "none"
Or on the markup, try using the following attribute on the control...
style="display:none"
Upvotes: 2