Monday, March 26, 2012

PageMethods not found (Javascript Error)

Hey Guys,

the following is my aspx page

<"C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default" %>




<title>Untitled Page</title>







function getme()











The following is my code behind

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Web.Services;

publicpartialclass_Default : System.Web.UI.Page


protectedvoid Page_Load(object sender,EventArgs e)



[WebMethod()]publicvoid getResults()


lblText.Text ="Sridhar";



The Current Version only support static method for Page Methods. So you cannot access the other element of the page.

Modify your page method return a string, then set lblText's value on the client side. This is an example of doing exactly that:

No comments:

Post a Comment