i just want to simply make a webmethod call from a asp button. When i use a html button it works perfectly but the asp button does not work. my Default.aspx page is <%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> <html> <head> <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script src="Scripts/myjscript.js" type="text/javascript"></script> </head> <body> <input type="submit" value="Submit" id="btnSubmit"/><br/> <form id="form1" runat="server"> <asp:Button runat="server" ID="btnasp" Text="ASP Button"/> </form> </body> </html> and Default.aspx.cs code is using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Services; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } [WebMethod] public static string getDate() { return DateTime.Now.ToString(); } } } Jscript file is $(function () { $("#btnSubmit").bind("click", onClick); $("#btnasp").bind("click", onASPClick); }); function onClick() { alert("I am a HTML Submit Button"); callMethod(); } function onASPClick() { alert("I am a Asp.net Button"); callMethod(); } function callMethod() { $.ajax({ url: 'Default.aspx/getDate', type: "POST", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { alert(data.d); } }); } somebody please help.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)