Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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

share|improve this question

1 Answer 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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.