HentaiAnimeMan
New Member
I'm trying to access a server side method from a client side one (that is just calling a server method from javascript). I'm using .NET 4.0 Visual Studio 2010 Ultimate. I'm building a web control (ascx).I have an ascx page (the control's html) and an ascx.cs page:The ascx is the following:\[code\]<%@ Control Language="C#" AutoEventWireup="true" CodeFile="BoxButton.ascx.cs" Inherits="ATB.Controls._BoxButton" %><asp:ScriptManager ID="SM_ScriptManager" runat="server" EnablePageMethods="true" /><script type="text/javascript"> function handle() { PageMethods.manageHandler(); }</script><span id="BoxButton_HtmlSpan" runat="server" onclick="handle();" style="background-color:#efefef;border-style:solid;border-width:1px;border-color:#cccccc;height:25px;text-align:center;padding:3px 3px 3px 3px;font-family:Arial, Helvetica, sans-serif;font-size:12px;font-style:normal;color:#333333;line-height:15px"> <asp:Label runat="server" Text="Button" id="Text_Label"></asp:Label></span>\[/code\]And the ascx.cs file is this one (just printing the function):\[code\][System.Web.Services.WebMethod] public static string manageHandler() { int i = 0; System.Console.WriteLine("Ciao"); return "Hello";}\[/code\]Well, as you can see I'm trying to solve my problem through pagemethods, well it does not work and I always getPageMethods is undefined b y the JScript runtime manager.Well, is it possible that PageMethods are not available in .net 4.0?Anyway, is there another approach for solving the problem regarding server side method calling from client side scripts? I understood that pagemethods are nothing more than a web service, and this bothers me a little when thinking about security in my web app.EDIT:Well, it seems that jQuery is a valid solution... but is it able to allow me to call a server side method? I expect to be because we're talking about ajax right?EDIT 2:Ah... Another question... I tried to use a webmethod but it does not work getting me errors not finding PageMethods in javascript while I set scriptmanager and method's attribute WebMethod as specified....Is it because I'm working inside an ascx?????? possible????? Then, even jQuery will not help....