2010-11-04 61 views
0

我有代码的类(简体):如何从一个类在C#中返回一个值到另一个(ASP.NET 2.0)

namespace CustomerData 
{ 
    public class InsertCustomer 
    { 
    public string name { get; set; } 
     public string customerID { get; set; } 

    public string Add() 
    { 
     //Insert into a database 

     //Condition to check if the insert was successfull 
     if (successful) 
     { 
      return id; 
     } 
     else 
     { 
      //If the insert was not successfull 
     } 
    } 


    } 
} 

现在我想这个值传递给我的web服务( ASP.NET 2.0)中相同的溶液如上述(简化的代码中的类):

namespace CustomerData 
{ 
    [WebService(Namespace = "http://tempuri.org/")] 
     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
     [System.ComponentModel.ToolboxItem(false)] 
    [System.Web.Script.Services.ScriptService] 

    [WebMethod] 
     public string deleteCustomer(string customerID) 
     { 
      return customerID; 
     } 

并且基本上我然后想有一个AJAX GET函数得到这个ID和与此变量,但如果执行一个功能我可以让我的WebMethod的价值,我想我会很好。

关于如何做主题描述的任何建议? 在此先感谢。

回答

0

您是否考虑过从您的InsertCustomer类调用Web方法?

CustomWebService srv = new CustomWebService; 
    srv.deleteCustomer(returnedCustomerID); 
相关问题