c# - why is this page method failing? -


I have my script manager, which are capable of apprentibles to enable. However, for some reason it is vigilant that I have failed. Public Partial Class _Default: System.Web.UI.Page {Secure Zero Page_load (Object Sender, EventArgs E) {} [WebMethod ()] Public Fixed String Test () {Return "q343242342342"; }} & Lt; Script type = "text / javascript" src = "http://code.jquery.com/jquery-latest.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Function CallMath () {PageMethods.test (On Success, On Falir); } Success on the ceremony (Results) {Warning (Results D); } Failure on function (error) {warning ('unsuccessful'); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = "form1" runat = "server" & gt; & Lt; Asp: ScriptManager id = "ScriptManager1" runat = "server" EnablePageMethods = "True" & gt; & Lt; / ASP: ScriptManager & gt; & Lt; Div & gt; & Lt; Asp: button id = "button1" OnClientClick = "callMethod ()" runat = "server" text = "button" />

This code works for me - can not tell exactly where your problem is Do not consider code in runat = server block (assuming you're just copying from code). But this exact code should work - I think.

  & lt;% @page language = "c #" autoevolutionwireUP = "true" codebahind = "default.aspx.cs" inherits = "web application 1. default"% & gt; & Lt; Html & gt; & Lt; Head runat = "server" & gt; & Lt; Title & gt; Sample page & lt; / Title & gt; & Lt; Script runat = "server" & gt; Secure Zero Page_load (Object Sender, EventErgus E) {} [System. Web. Services Webmath ()] Public Static String Test () {Return "Q 343242342342"; } & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "http://code.jquery.com/jquery-latest.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Function CallMath () {PageMethods.test (On Success, On Falir); } Success on the ceremony (results) {Warning (results); } Failure on function (error) {warning ('unsuccessful'); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = "form1" runat = "server" & gt; & Lt; Asp: ScriptManager id = "ScriptManager1" runat = "server" EnablePageMethods = "True" & gt; & Lt; / ASP: ScriptManager & gt; & Lt; Input type = "button" id = "btn" value = "click me" onclick = "callMethod ();" / & Gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -