Modify the text inside an Html.EditorFor MVC with jquery?

304 views Asked by At

I'm working on a web application in which I have an EditorFor field for a date as follows:

 @Html.EditorFor(model => model.FECHA_RETIRO, new { htmlAttributes = new { @class = "form-control datepicker" } })

I have a jquery method that selects an element from a dropdown list and depending on the selection has to retrieve its date from the database. The method is:

 $("#SIGLA_CURSO").change(function () {
        var selectedValue = $("#SIGLA_CURSO").val();
        $.post('@Url.Action("obtenerFechasCurso", "PRESTAMOes")', { idCurso: selectedValue }, function (listaDatos) {
        alert(listaDatos);
            // handle the server response here
            $("#FECHA_RETIRO").val(listaDatos[0]);
            $("#Fecha_Fin_Prestamo").val(listaDatos[1]);
        });
     });

The thing is I want the FECHA_RETIRO field to show the date that I retrieve from the database, however I can't get to modify it. If I try to show a date in a textbox it works, but it doesn't using the editorfor and I think that that is the field I need to modify.

Is it possible using jquery? Thank you.

0

There are 0 answers