Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Saied 349 posts 674 karma points
    Sep 15, 2015 @ 13:36
    Saied
    0

    UmbracoContext.Current.PageId is null when using form get?

    I changed from using @Html.BeginUmbracoForm with a GET to just form with a GET. The form works, but when I click submit, it throws and error in my model:

    UmbracoContext.Current.PageId is null where PageId is null. I tried removing the inheritetance from RenderModel and SurfaceController and just using an MVC controller, but now in my ajax call, it returns the whole HTML document instead of the JSON object.

    Here is my ajax call:

     $yearDropDownList.on('change', function () {
            $.ajax({
                url: $makeDropDownList.attr('data-request-url'),
                method: 'GET',
                dataType: 'json',
                data: { year: $yearDropDownList.find(':selected').val() },
                success: function (data) {
                    $makeDropDownList.empty();
                    $makeDropDownList.append($('<option/>', { value: "-1", text: "MAKE" }));
                    $makeDropDownList.find('option[value="-1"]').prop('disabled', true);
                    $makeDropDownList.find('option[value="-1"]').prop('selected', true);
                    $(data).each(function (index, item) {
                        $makeDropDownList.append($('<option/>', { value: item.Id, text: item.Name }));
                    });
                    $makeDropDownList.prop('disabled', false);
                },
                error:function(x, y, z) {
                    console.log(x);
                    console.log(y);
                    console.log(z);
                }
            });
    
        });
    
Please Sign in or register to post replies

Write your reply to:

Draft