隻找Java工作

胡說—八道。胡言-亂語。 但不騙你
正文

別讓WCF嚇著了-Create AJAX WCF

(2011-10-25 12:55:28) 下一個


Create AJAX WCF and AJAX
WCF--Windows Communication Foundation , 以下隻是2,3兩步是重要的。
1.new project (eg “ empty web application”)
2.create a “WCF AJAX-enabled service”
     2.1 project in the Solution Explorer window and select Add, then New Item
     2.2 Name the service (eg." NewService.svc ") in the Name box and click Add.
3. To Create " ScriptManager"  and configure the client to access the service
      3.1 add ScriptManager to *.aspx
     3.2 Right-click the ScriptManager and select Properties.
      Expand the Services collection in the Properties window to open up the ServiceReference Collection Editor window.
Click Add, specify (eg. NewService.svc , it is AJAX Service 's file name ) as the Path referenced, and click OK.

Code: < asp : ScriptManager ID ="ScriptManager1" runat ="server">
< Services >
< asp : ServiceReference Path ="NewService.svc " />

4. done add code to service and *.aspx/*.aspx.cs
       4.1 *.aspx.cs can reference service(auto add reference)
        4.2 write test "Contract" in  NewService.svc
[ OperationContract ]
public double CostOfSandwiches( int quantity)
{ return 1.25 * quantity; }

4.3 *.aspx
           code in aspx and *.cs(add label to *.aspx , and code in *.apsx.cs)

protected void Page_Load(object sender, EventArgs e)
{
CostService abc = new CostService ();
Label1.Text = abc.CostOfSandwiches(6).ToString(); }
 

[ 打印 ]
閱讀 ()評論 (0)
評論
目前還沒有任何評論
登錄後才可評論.