I tried everything but couldn't get rid of the "PageMethods is Undefined". Also I couldn't get the webservice to work from the javascript. Please can someone have a look at this code and point out the error? I tried putting 'static' in front of SomeMethod(), but it still doesnt work. I was wondering if there may be any deployment issue!
default.aspx.cs file
public
partialclassDefault : System.Web.UI.Page{
protectedvoid Page_Load(object sender,EventArgs e){
}
[
WebMethod]public string SomeMethod(string name){
return name;}
}
default.aspx
<formid="Form2"runat="server"><asp:ScriptManagerrunat="server"ID="scriptManager"></asp:ScriptManager><div>
Search for
<inputid="SearchKey"type="text"/><inputid="SearchButton"type="button"value="Search"onclick="DoSearch()"/></div><scripttype="text/javascript"language="javascript">function DoSearch(){
PageMethods.SomeMethod(
"HiThere", OnRequestComplete);}function OnRequestComplete(result){
alert(result);
}
</script></form>Thanks
Richmond
I got the answer from the following discussion. It works!
http://forums.asp.net/thread/1457956.aspx
No comments:
Post a Comment