Reputation: 3757
I Have a USerBO like this
[Serializable]
public class UserBO
{
public string userId { get; set; }
public string userCode { get; set; }
public string userGroup { get; set; }
}
Have retrieved this Object from session. Now I need to pass this Object (USerBO) from javascript to a C# webmethod using JSON. Is it possible ?
Upvotes: 0
Views: 502
Reputation: 60570
When you say webmethod, are you using an ASPX page method or ASMX ScriptService? If so, the answer is that it's very easy to send that object from the browser to your method.
A page method like this one:
[WebMethod]
public bool SaveUserBO(UserBO User) {
// Assuming you had a .Save() method on that class, for example.
return User.Save();
}
Would automatically hydrate its User
parameter if you passed it JSON like this:
{'User':{'userId':42,'userCode':1,'userGroup':2}}
Upvotes: 1