我有一个网络用户控件,我想从它调用Web服务。我的主要动机是什么:如何从asp.net中的web用户控件调用web服务?
1.我正在为高级搜索创建一个Web用户控件,为此我将绑定字段和按钮[编辑,删除]动态添加到GridView。 2.现在我正在使用ajax去编辑和删除(有具体的理由去这种方法,因为我已经提到,我动态地添加boundfields和按钮,首先im清除网格的所有列然后现在如果按钮的点击发射然后它回发的页面,这使得按钮将从网格消失,所以我想使用JSON的那个)
这是我的代码grid ::
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" CellPadding="4"
BorderWidth="1px" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<FooterStyle BackColor="#990000" ForeColor="White" Font-Bold="True" />
<HeaderStyle Height="30px" BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#333333" HorizontalAlign="Center" BackColor="#E2E2E2" />
<RowStyle CssClass="test" BackColor="#E2E2E2" Height="25px" BorderWidth="1px" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2E2E2" Font-Bold="True" ForeColor="Navy" />
<SortedAscendingCellStyle BackColor="#FDF5AC" />
<SortedAscendingHeaderStyle BackColor="#4D0000" />
<SortedDescendingCellStyle BackColor="#FCF6C0" />
<SortedDescendingHeaderStyle BackColor="#820000" />
</asp:GridView>
下面是对JSON调用的代码
$('.DeleteButton').live('click', function() {
alert('hellllo');
$.ajax({
url: '<%=ResolveUrl("~/Control/WebService/WebService.asmx/HelloWorld") %>',
data: "{ }",
dataType: "json",
type: "POST",
contentType: "application/json;charset=utf-8",
success: function() {
alert('hi;');
},
error: function() {
alert('Record could not be deleted. \n Please try again later. hye');
},
failure: function() {
alert('Record could not be deleted. \n Please try again later. hello');
}
});
});
我总是收到以下错误:
500内部错误 请帮我摆脱这种概率我被困在它从过去的2天。
500意味着错误是在你的服务。 – Schaliasos 2013-03-20 10:58:25
@Schaliasos什么样的错误,我该如何解决 – 2013-03-20 10:59:53
是一个'内部服务器错误',你在它的描述中看到。你需要找出你的服务出了什么问题。你使用日志记录? – Schaliasos 2013-03-20 11:01:04