1

I have a bunch of [System.Web.Services.WebMethod] that I call with jquery to provide ajax functionality. Is there to call them from my codebehind files?

Meaning I have the following WebMethod in a file called DeleteImages.aspx.cs

 [System.Web.Services.WebMethod]
public static string deleteImage(int id, int itemID, string fileName)
{
    string deleteSQL = "DELETE FROM tItemsFiles WHERE ID=@ID";
    //run sql command
}

is there a way I can call this webmethod from a different codebehind file, ie CreateImage.aspx.cs

1 Answer 1

1

Yes, you should be able to do call it directly from CreateImage:

DeleteImages.deleteImage(123, 456, "image.png");

(Note that I'm not sure what your actual namespace or class names are. It's almost certain that the class name of DeleteImages.aspx.cs will be DeleteImages, but you may need to prefix it with a namespace when calling it, or have a using directive at the top of your CreateImage class.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.