Try our conversational search powered by Generative AI!

PageTypeBuilder error in AJAX request

Vote:
 

Hello everybody,

I have a website in CMS 6 that uses PageTypeBuilder. Everything works fine except that in one of the page templates i need to make an ajax request, and after declaring a [webmethod] on server side when i try to call it from javascript then i get the following  PTB error "The current page is not of type MyPagePersonalInformation. This often occurs when no id query string parameter is specified".

The ajax call as well as the method on server side are very simple for testing purposes.

$("#fileUpload").change(function () {
                $.ajax({
                    type: "POST",
                    url: "/Templates/BW/Pages/MyPageInformationPage.aspx/UploadFile",
                    success: function (msg) {
                        alert(msg);
                    }
                })
            });

 

 [WebMethod]
        public static string UploadFile()
        {
            return "uploaded";
        }

 

Any ideas of what the problem could be?

Thanks in advance,

 

/Kenia

 

#57996
Apr 10, 2012 10:03
Vote:
 

MyPageInformationPage.aspx probably inherits from TemplatePage<MyPagePersonalInformation>, and because you don't specify a "correct" pageid, PTB tries to cast the page to a faulty pagetype.

I would put the UploadFile in a seperate webservice/page or just specify a pageid in the AJAX-request.

#58003
Apr 10, 2012 15:50
Vote:
 

Hej and thanks for your reply!

Eventually I implemented another solution, but it sounds like your idea would have worked as well, i just didn't come up with it. Something to take into account in the future. Thanks!

/Kenia

#58333
Apr 19, 2012 16:03
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.