One of the easiest thing in Atlas is to use the
Page Method feature. If you use Atlas on your web page say
Default.aspx, you can directly call public methods on Default.aspx
from javascript. Just put a [WebMethod] attribute on a public
method in Default.aspx and then you can them from Javascript using
PageMethods.MethodName().
: System.Web.UI.Page { protected void Page_Load( object sender,
EventArgs e) { } [WebMethod] public string DoSomething( string param)
{ return param; } }
On the client side you can call this method like this:
‘ Hi ‘
, function (result) { alert(result); } );
Here’s the catch, Page method calls are always HTTP POST calls.
You can never make HTTP GET call to the Page methods but you can
make HTTP GET calls to Web service method. So, on later stage of
your project when you will need Http response caching in order to
save roundtrips, you will have to refactor all page methods to web
service methods and for this you will have to move all public
methods and related code from default.aspx to some web service. So,
try not to use Page methods from Day 1.
I have been awarded MVP Award 2007 on Visual C# again. This is my second year. This time the gifts are…
I have been awarded MVP Award 2007 on Visual C# again. This is my second year. This time the gifts are
You’ve been kicked (a good thing) – Trackback from DotNetKicks.com
To add more info about the PageMethods, in Beta 2, the PageMethods work only if you have placed the code in “in-line” page (in .aspx, not in .aspx.cs).
Check http://forums.asp.net/thread/1459613.aspx out for this bug.
Just my 0.02!
Torrie Wilson in a thong
http://torriewilson.cn.to
This is no longer true in ASP.NET AJAX RC 1.
[WebMethod]
[ScriptMethod(UseHttpGet=true)]
public static string PageMethodTest(string name)
{
return String.Format(“Hello {0}”, name);
}
works absolutely fine and it can be in the code behind file (as opposed to inlining bug in Beta2).
Shiva –
How about in ascx files. Previously we had to use AJAXPro.Net in order to make this work in user controls. Is this functionality availble in Ajax.Net 1.0.
Thanks for your response,
Ben
USE page methods . they are really amazing. and avoid post back.and does your work
—
SHERYAR NIZAR
http://sheryar.net
Klonopin side effects. Klonopin under eye. Pharmaceutical company klonopin. Klonopin. Klonopin withdrawal.