CSharp Binding To Web Service – ADO.Net Database

File: TimeService.asmx<%@ WebService Language="C#" Class="TimeService" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;[WebService(Namespace = "http://www.w3mentor.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class TimeService  : System.Web.Services.WebService {    [WebMethod]
    public DateTime GetServerTime() {
        return DateTime.Now;
    }
}
File: Default.aspx<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <form id="form1" runat="server">
    <div>    <asp:FormView
        id="frmServerTime"
        DataSourceID="srcServerTime"
        CssClass="serverTime"
        Runat="server">
        <itemTemplate>
        The remote server date and time is: <%# Container.DataItem %>
        </itemTemplate>
    </asp:FormView>    <asp:ObjectDataSource
        id="srcServerTime"
        TypeName="TimeService"
        SelectMethod="GetServerTime"
        Runat="server" />    </div>
    </form>
</body>
</html>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.