/// bu uygulama için ajax scriptlere ihtiyacınız var. asp.net den temin edebilirsiniz.
/// bu yapı kullanılarak ver itabanından veri çekilip geriye döndürülebilir. şimdilik ver iyapısını bir class
//aracılığı ile yaptım. bir sonraki örnekte veri tabanından veri çekip geri döndürmeyi yaparız.
//=========== wcf service ============= using System.Collections.Generic; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Activation;
[DataContract] public class dbClass { [DataMember] public int id { get; set; }
[DataMember] public string adi { get; set; }
[DataMember] public string soyadi { get; set; } }
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "dbService" in code, svc and config file together. [ServiceContract(Namespace = "dbService")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class dbService { //[WebGet(ResponseFormat=WebMessageFormat.Json)] [OperationContract] public List<dbClass> getVeris(string orderprm) { List<dbClass> veriler = new List<dbClass>(){ new dbClass() { id = 1, adi = "murat", soyadi = "turan" }, new dbClass() { id = 2, adi = "ali", soyadi = "turk" }, new dbClass() { id = 3, adi = "kemal", soyadi = "tepeli" }, new dbClass() { id = 4, adi = "hasan", soyadi = "keles" }, new dbClass() { id = 5, adi = "çağlar", soyadi = "kızılarslan" } };
//WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Json;
return veriler; }
[OperationContract] public string GetTest() { return "Murat Turan"; } }
//== webconfig == <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly="System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> </assemblies> </compilation> </system.web> <system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> <services> <service behaviorConfiguration="dbServiceBehavior" name="dbService"> <endpoint address="" behaviorConfiguration="dbServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="dbService" /> </service> </services> <behaviors> <endpointBehaviors> <behavior name="dbServiceAspNetAjaxBehavior"> <enableWebScript/> </behavior> </endpointBehaviors>
<serviceBehaviors> <behavior name="dbServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors>
</system.serviceModel> </configuration>
//== web form == <%@ Page Language="C#" AutoEventWireup="true" CodeFile="tmpl_5.aspx.cs" Inherits="tmpl_5" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd - http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" http://www.w3.org/1999/xhtml - http://www.w3.org/1999/xhtml "> <head runat="server"> <title></title>
<style type="text/css"> .sys-template { visibility:hidden; display:none; } </style>
<script src="Scripts/MicrosoftAjax/jQueryStart.js" type="text/javascript"></script>
<script type="text/javascript">
//dataview ve webservice client script leri yukleniyor //Sys.require(Sys.components.dataView); //Sys.require(Sys.scripts.WebServices); Sys.require([Sys.components.dataView, Sys.scripts.WebServices]);
Sys.onReady(function () {
$("#customers-template").dataView( { dataProvider: "dbService.svc", fetchOperation: "getVeris", fetchParameters: { orderprm: "adi" }, autoFetch: "true" } ); }); </script>
</head> <body xmlns:sys="javascript:Sys"> <form id="form1" runat="server"> <div> <table border="1"> <thead> <tr> <th>id</th> <th>adi</th> <th>soyadi</th> </tr> </thead> <tbody id="customers-template" class="sys-template"> <tr> <td>{{id}}</td> <td>{{adi}}</td> <td>{{soyadi}}</td> </tr> </tbody> </table> </div> </form> </body> </html>
------------- http://www.kasatakip.com - Kasa Takip | http://www.caritakip.com - Cari Takip | http://www.evraktakip.com - Evrak Takip | http://www.etasqlmobil.com - ETA SQL Mobil
|