1
Good afternoon, I have the following code:
<asp:GridView runat="server" Style="border: 0px !important;" ID="gdvDadosHistoricoMedico" OnRowDataBound="gdvDadosHistoricoMedico_RowDataBound"
AutoGenerateColumns="false" ShowHeader="false" Visible="false">
<AlternatingRowStyle />
<RowStyle />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<local:UCHistoricoAtendimentoMedico runat="server" ID="UCHistoricosAtendimentoMedicos" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Inside the user control I have fields that I would like to get the value with jquery by clicking a button:
<div class="col-sm-4">
<governa:GVNCalendar ID="cldDataMedicamento" DiasLimiteFinal="7" Tipo="Data" runat="server" Requerido="True" />
</div>
<div class="col-sm-1">
<asp:Label ID="lblCMHora" Text="Hora" runat="server"></asp:Label>
</div>
<div class="col-sm-4">
<governa:GVNCalendar ID="cldHoraMedicamento" Tipo="Hora" ClientIDMode="AutoID" runat="server" Requerido="True" />
</div>
<asp:HiddenField ID="hdfCodPrescricaoObservacao" runat="server" />
<asp:HiddenField ID="hdfCodUsuarioResponsavel" runat="server" />
<asp:HiddenField ID="hdfNomUsuarioResponsavel" runat="server" />
<div class="col-sm-1">
<button ID="GravarHorario" onclick="AdicionarNaTabela()">Clique</button>
</div>
What would be the javascript/jquery code to get the value? I tried it this way and it didn’t work:
function AdicionarNaTabela() {
var cldDataMedicamento = $('#<%=cldDataMedicamento.ClientID %>').val;
var cldHoraMedicamento = $('#<%=cldHoraMedicamento.ClientID %>').val;
var hdfCodPrescricaoObservacao = $('#<%hdfCodPrescricaoObservacao.ClientID %>').val;
var codProfissional = $('#<%=hdfCodUsuarioResponsavel.ClientID %>').val;
var nomProfissional = $('#<%=hdfNomUsuarioResponsavel.ClientID %>').val;
}
Actually, this was one of the errors of my code, but now I have another problem, jquery always recovers the value of the last User Control of grid view. Any hint?
– Guilherme Campos
@Guilhermecampos glad the answer was useful, please mark it as useful, as an answer (since she solved her question "What would be the javascript/jquery code to get the value?") and close. So the question of the initial scope will not be open waiting for answers. As for this other question, which appeared later (as it is in your comment "...but now I have another problem..."), you should detail better in another question so that all users (including myself) can understand better and help you.
– Renan