1

I Have an object 'Person' in C#, and I want to return this object in WebMethod.

  [WebMethod]
    public static Person LoadPerson(string id)
    {
      return sdb1.Persons.Where(x =>x.PersonID.ToString().Equals(id)).FirstOrDefault();   
    }

and in JS:

function LoadPerson(id) {

    PageMethods.LoadPerson(id,onSucess, onError);

    function onSucess(result) {
        alert();
    }

    function onError(result) {
        alert('Something wrong.');
    }

   }

How can I return this object? I want for example to alert onSucess the Person fullName. (there is Attribute field 'FullName')

Thank you!

1 Answer 1

1

You can just return it.

When you add this Client in your front-end or another application, the webmethod object will contains your returning object.

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.