【发布时间】:2011-08-13 08:22:05
【问题描述】:
我想在ASP.NET WebForms中使用jQuery ajax,我想直接调用一个web服务方法:
$.ajaxWrapper('/services.asmx/createprofile', {
firstName = firstName,
lastName = lastName,
city = city,
state = state,
address = address,
postalCode = postalCode,
tell = tell,
cellPhone = cellPhone,
isCompany = isCompany }, function(r){
// success callback; return value is in r parameter.
});
注意:换行仅用于演示目的。
但是,由于字段的数量比这还要多,而且所有字段都是必需的,所以我不想创建一个 Web 服务方法来获取所有内容作为参数:
[WebMethod]
public bool CreateProfile (string firstName,
string lastName,
string city,
string state,
string address,
string postalCode,
string tell,
string cellPhone,
bool isCompany)
{
}
有没有像 ASP.NET MVC 模型绑定这样的方法来让框架发挥作用?换句话说,我可以这样写我的网络服务代码吗:
[WebMethod]
public bool CreateProfile (UserProfile profile)
{
}
【问题讨论】:
标签: asp.net web-services jquery webforms