You are on page 1of 2

Default.

aspx

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEven tWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication7._Default" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent "> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <script type="text/javascript""> function getResult() { var fno = $get("fno").value; var sno = $get("sno").value; WebApplication7.SLKMathService.Add(fno, sno, onSuccess); } function onSuccess(result) { alert(result); } </script> <h2> Welcome to ASP.NET! </h2> <p> To learn more about ASP.NET visit <a href="http://www.asp.net" title="AS P.NET Website">www.asp.net</a>. </p> <p> You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368 &amp;clcid=0x409" title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>. </p> <asp:ScriptManager runat="server" ID="sm"> <Services> <asp:ServiceReference Path="~/SLKMathService.asmx" /> </Services></asp:ScriptManager> <p> Enter first number: <input type="text" id="fno" /><br /> Enter second number: <input type="text" id="sno" /><br /> <input type="button" value ="FindSum" onclick="getResult()"/><br /> </p> </asp:Content> --------------------------------------------------------------SLKMathService.asmx

using using using using using

System; System.Collections.Generic; System.Linq; System.Web; System.Web.Services;

using System.Web.Script.Services; namespace WebApplication7 { [WebService(Namespace="com.slk.www")] [ScriptService] public class SLKMathService { [WebMethod] public int Add(int fno,int sno) { return fno+sno; } [WebMethod] public int Subtract(int fno,int sno) { return fno-sno; } } }

You might also like