Ellen
Ellen

Reputation: 178

Getting error "Unknown web method" when trying to call aspx.vb page

I know this has been asked, but I keep getting this error on a method I added, no matter what I do.

I think I've read all the posts on this (and have Googled it all day long), but nothing seems to work. I'm new to web development.

Is there something I need to do so that the page gets refreshed somehow? It works fine on my machine, but when I do a clean/rebuild solution and a new build, and then try to access it via the server, I get the error.

I've tried removing the "Shared"... The sPath is correct...

function SaveServerSideAJAXContinue(SaveMode) 
{

var sPath = window.location.pathname;
var data = JSON.stringify("");
var JSONData = "{ Data:" + data + "}";

$.ajax({
    type: "POST",
    data: JSONData,
    url: sPath + "/GetPreSaveMethod",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (jsonresult) {
        eval(jsonresult.d);
        PerformServerSave(SaveMode);
    },
    error: function (jqXHR, testStatus, errorThrown) {
        var myWindow = window.open("", "MsgWindow", "width=1000, height=800");
        myWindow.document.write(jqXHR.responseText);

        PerformServerSave(SaveMode);
    }
});
}


   <System.Web.Services.WebMethod()> _
    Public Shared Function GetPreSaveMethod(ByVal Data As String) As String
        Return GetPreSave()
    End Function


    Private Shared Function GetPreSave() As String

        Dim MidasObj As MidasObjInstance = MidasObjGet()
        Dim PreSaveMethod As String = MidasObj.UserForm.PreSaveMethod

        Return PreSaveMethod
    End Function

If any of this looks goofy, it's probably because I've been trying all kinds of stuff and my mind is shot at this point. Any help greatly appreciated!

Upvotes: 0

Views: 273

Answers (1)

sclarson
sclarson

Reputation: 4422

You can try resolving the webmethod and putting that in a JS variable then posting to that.

<script> var webMethodUrl = '<%=ResolveUrl("~/<ASMXILENAMEHERE>/GetPreSaveMethod") %>';</script>

Upvotes: 1

Related Questions