locked
How to pass Model from view to controller in MVC RRS feed

  • Question

  • Hi All

    The code is written in MVC architecure.

    I am using this script

    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnSubmit").click(function (e) {
                e.preventDefault();
                // var val = Json.Encode(Model);
                    $.ajax({
                        type: 'POST',
                        url: '../Apteka/UpdateParial',
                        data: JSON.stringify(@Html.Raw(Json.Encode(Model))),                                  
                        contentType: 'application/json; charset=utf-8',
                        dataType: "json",
                        success: function (data) {
                            alert('Success');
                        }
                    });
                });
            });
        </script>

    My controller is 

      public ActionResult UpdateParial(AptekaReportModel aptekaReportModel)
            {
                
                aptekaReportModel.YearList = CommonFunctions.GetYear();
                aptekaReportModel.MonthList = CommonFunctions.GetMonth();
                // aptekaReportModel.RepresentativeTypeList = CommonFunctions.GetRepresentativeTypeList();
                aptekaReportModel.IsSearch = true;

    It is passing all everything except selected value in dropdown.

    How to send the selected value of dropdown to controller from view using ajax call


    Prashant Arora

    Wednesday, January 14, 2015 1:10 PM

Answers

  • Hello,

    Since this is an ASP.NET MVC question, I would recommend you to re-post this question to the ASP.NET forum here: http://forums.asp.net/1146.aspx/1?MVC.

    Thanks,

    Prashant


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    • Proposed as answer by Just Karl Tuesday, January 20, 2015 10:09 PM
    • Marked as answer by Just Karl Wednesday, January 28, 2015 11:11 PM
    Wednesday, January 14, 2015 7:20 PM

All replies

  • Hello,

    Since this is an ASP.NET MVC question, I would recommend you to re-post this question to the ASP.NET forum here: http://forums.asp.net/1146.aspx/1?MVC.

    Thanks,

    Prashant


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    • Proposed as answer by Just Karl Tuesday, January 20, 2015 10:09 PM
    • Marked as answer by Just Karl Wednesday, January 28, 2015 11:11 PM
    Wednesday, January 14, 2015 7:20 PM
  • Done

    Prashant Arora

    Wednesday, January 21, 2015 6:19 AM