2010-11-04 39 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); 
相關問題