调用本地解决方案中的WebService
添加新项->Web服务(WebService.asmx)
在WebService.cs中添加方法(简单加法)Add(int a,int b)
代码:
[WebMethod]
public int Add(int a,int b) {
return a+b;
}
保存
在WebPage(Default.aspx)中调用
先添加web引用->此解决方案中的Web服务->添加WebService.asmx引用(引用名;testWebService)
在Default.aspx中的添加TextBox1,TextBox2,label1,button1
在button1的触发事件中添加调用代码:
testWebService.WebService test=new testWebService();
int a=Convert.ToInt32(TextBox1.text);
int b=Convert.ToInt32(TextBox2.text);
int c;
c=test.Add(a,b);
label1.text=c.toString();