在C#asp.net中加载页面上的Web服务调用 [英] web service call on page load in C# asp.net
本文介绍了在C#asp.net中加载页面上的Web服务调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在C#asp.net中页面加载时调用Web服务...?
请帮助我....
解决方案
< blockquote>假设这是你的web服务方法
[WebMethod]
public string WelcomeUser( String _userName)
{
return 欢迎您: + _userName;
}
并且您希望在页面加载页面时使用该服务。在这种情况下,您只需要创建服务代理的对象并使用该对象来访问这样的文件方法:
HelloWorld.Service _objHello = new HelloWorld.Service();
_objHello.WelcomeUser( Guest);
希望这个帮助
-SG
尝试以下链接。
添加和删除Web引用
使用ASP.NET调用Web服务
使用ASP.NET Web服务
< blockquote>只需将您的调用代码放在代码中的Page_Load方法中:
protected void Page_Load(object sender,EventArgs e)
{
//确保这不是postBack事件..
if(!Page.IsPostBack)
{
webService.myMethod();
}
}
How to call web service on page load in C# asp.net...?
please help me....
解决方案
suppose this is you web service method
[WebMethod] public string WelcomeUser(String _userName) { return "You are Welcome : " + _userName; }
and you want to use that service in your page load of a page. IN that case you simply need to create the object of the service proxy and use that object to access the wen method like this:
HelloWorld.Service _objHello = new HelloWorld.Service(); _objHello.WelcomeUser("Guest");
Hope this help
-SG
try following links.
Add and Remove Web References
Calling Web Service using ASP.NET
Using ASP.NET Web Services
Simply put your calling code in the Page_Load method in your code behind:
protected void Page_Load(object sender, EventArgs e) { // make sure this is not a postBack event.. if (!Page.IsPostBack) { webService.myMethod(); } }
这篇关于在C#asp.net中加载页面上的Web服务调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文