what about the code-behind (code behind)

One MAJOR difference between AJAX.NET and Atlas.NET seems to be that AJAX.NET is able to expose methods in your codebehind to the client.

Why doesn't Atlas do this? Or am I mistaken?

With AJAX.NET it's just a simple line or two:


<Ajax.AjaxMethod()>Public Function myFunction

PLEASE tell me Atlas has something comparable to this. I don't have the time to rewrite all my code-behind methods in javascript or atlas script.

3/28/2006 8:33:28 PM
asp.net.ajax-discussion 13973 articles. 1 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 31
Get it on Google Play
Get it on Apple App Store

All you need to do in Atlas to expose a method on your page (or its code behind class) is to put a [WebMethod] attribute on it.  See here for an example.


3/28/2006 10:30:26 PM

well, i did try that. but it didn't work. i dont know if it needs to specify the namespace in the code-behind or in the aspx page, but i can't the javascript to work.

here's my codebehind ... 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;

    public partial class sendersearch : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)

        public string Login(string user, string pass)
            return "success";



and here's my aspx page... 

"C#" AutoEventWireup="true" CodeFile="sendersearch.aspx.cs" Inherits="sendersearch" %>

 <head id="Head1" runat="server">
   <atlas:ScriptManager runat="server" ID="scriptManager" EnableScriptComponents="true"&gt;
       <atlas:servicereference path="sendersearch.aspx.cs" />
<script type="text/javascript">
   function DoLogin(){
        sendersearch.Login('',''); //sendersearch is the name of the page (and the class in the code-behind)

  <form id="Form1" action="" runat="server">
<div> <input type="button" value="Login" onclick="DoLogin()" /> <br /> </div> </form> </body>
3/29/2006 1:31:43 PM

forget it. i found out what it was.

you've got to use a keyword when referring to the method in the code behind (or in a page method). the keyword is 'PageMethod'. duh.

for example....


3/29/2006 2:09:18 PM

Correct.  Also, you don't need your atlas:servicereference tag, as PageMethods are automatically available.


3/29/2006 4:03:26 PM

I've tried to get a variation of this to work in vb -- could you tell what I'm doing wrong:

Here's my .aspx file:


@ Page Language="VB" AutoEventWireup="false" CodeFile="AtlasScriptWithCodebehind.aspx.vb" Inherits="AtlasScriptWithCodebehind" %>


DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"



html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<atlas:ScriptManager runat="server" EnableScriptComponents="true" ID="scriptManager">


<script type="text/javascript">

function DoSearch()


var QuantityElem = document.getElementById("quantity");

var ProductIDElem = document.getElementById("productID");

AtlasScriptWithCodebehind.PageMethod.HelloWorld(ProductIDElem.value, QuantityElem.value, OnRequestComplete);


function OnRequestComplete(result)


var RsltElem = document.getElementById("Results");

RsltElem.innerHTML = result;



<style type="text/css">

body { font: 11pt Trebuchet MS;

font-color: #000000;

padding-top: 72px;

text-align: center }

.text { font: 8pt Trebuchet MS }




<form id="Form1" runat="server">


Add to Cart

<input id="productID" type="text" />

<input id="quantity" type="text" />

<input id="SearchButton" type="button"


onclick="DoSearch()" />



<hr style="width: 300px" />


<span id="Results"></span>






Here's my codebehind:
























Public Class AtlasScriptWithCodebehind

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

<WebMethod()> _

Public Function HelloWorld(ByVal productID As String, ByVal quantity As String) As String

quantity = Server.HtmlEncode(quantity)

productID = Server.HtmlEncode(productID)

If Not String.IsNullOrEmpty(quantity) Then

Return String.Format("Hello, your productID is {0} and your quantity input is {1}. The " _


"current time is {2}", productID, quantity, DateTime.Now)


Return "The query string was null or empty"

End If

End Function






I keep getting a javascript error on the page:

'AtlasScriptCodeBehind' is undefined.

Thank you so much. 

3/29/2006 9:12:10 PM

Ignore my last post -- the keyword in the javascript call should be PageMethods.HelloWorld not PageMethod.HelloWorld.


3/29/2006 9:23:19 PM

Similar Artilces:

Code Behind or not Code Behind
Ok i am confuse now.... A lot of books are showing pages without code behind (the code is integrated in the .aspx) Is it better to use the code behind or not. Is there any difference between using VB.NET or C#.NET except for the code synthax. Thank you and come again. A lot of samples show inline code just for simplicity.. i personally use code-behind because I like to seperate my code from presentation. As for VB.NET or C#, its your preference.. there is no difference really when its all said and done. From a purely mathematical sense, having everything in a single file would s...

Code behind vrs. non code behind in VS.NET 2003
Does anyone know what the advantages and disadvantages are for using code behind vrs. non code behind in Visual Studio.Net 2003? One important difference is that you are able to separate the design of a web site from the code. This makes for ease of maintainablity and much more structured applications. If you ever worked with classic ASP the code-behind is a great invention. sivilianMy Weblogs...

To Code Behind or Not Code Behind, That is the Question...
I have been working in ASP.Net 1.0 for several years.  I have just begun using 2.0 and I am really liking it. I understand how to create pages with code in the page and code behind the page.  I'm just not clear on what is considered the preferred method. I am about to start a new application and I would like to do it the recommended way. Are there any opinions on this already, something I should be reading? Thanks a lot,Chris Hi,  Generally, code behind, or code behind files are recommended, as they make applications easier to debug and rework.  I guess that the thi...

Code Behind vs. Non-Code Behind
If you do not use Code Behind will the only thing you need is the .aspx file??? What is the benefit of code behind? I want to know the benefits.Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/ The reason I ask about benefits is because everybook or place I read about ASP.net they do not, I repeat "DO NOT use CODE BEHIND" Even my MICROSOFT ASP.NET Step by Step book does not use it.Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/ From a runtime perspective there is very little difference, howev...

code behind vs non code behind
hi,How do I gain access to server objects and events when I am using code behind? When I am using code behind in C#, I do not have access to server objects & events on my drop down list. However, when I do not use code behind, I have access to server objects & events on my drop down list.  Thanks.  You always have access to server controls from code-behind.  If your dropdownlist ID="DDL1", you can access it using Me.DDL1Please remember to click “Mark as Answer” on the post that helps you.This can be beneficial to other community members reading the thread.T...

Sorting, Paging in Gridview with Code Behind (Code Behind ONLY!!!)
Does anyone know of a definitive tutorial of VB code-behind for paging and sorting parameters for GridViews?  I've been all over this site and I know more than I need to know about the SortExpression parameter, the ASP.NET tutorials on Paging and Sorting, and the many postings on these forums for same.  Please don't take the copout approach and give me links for what I've already read.  I'm specifically looking for something that gives a detailed explanation for such things as the PageIndexChanging, PageIndexChanged, SelectedIndexChanging, SelectedIndexChanged,...

Reference code-behind .js from another code-behind .js
I have a utility code-behind file in .js and I'm trying to add or reference to code in this file from another code-behind file in .js using the "import" feature. Anyone know how? Thanks... ...

Web Forms Designer error
Hi, The web forms designer keeps adding things in a generated InitializeComponent() method. I believe these things shouldn't be there because I've made a new webform with the same code that doesn't add the same stuff. Is there anyway I can see the Web Designer code? Thanks. Just expand out the hidden #region. It is labeled Web Form Designer CodeStarting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog...

Include Code-behind .js into another Code-behind .js file
I have a utility code-behind file in .js and I'm trying to add or reference to code in this file from another code-behind file in .js using the "import" feature. Anyone know how? Thanks... ...

Moving items from the page code behind to the user control code behind.
I am trying to setup a page with a user control specified as a header. Things work fine until the user control has to access dynamic content that is in the code behind of the main page. When I try to move these commands to the code behind for the user control I get errors saying items have not been declared. What is the best way to do this, I'm mainly trying to create some headers and footers for my asp.net project. if it belongs for the header move it to the headers code behind. It is probably saying items have not been declared because you moved the methods, but not the properties to...

reusable code
 I have a page of code that instead of putting it in each pags code behind, I would like to be able to jsut include it in the code behind of each page so that it gets executed each time. This way I could jsut edit the one file and th changes woudl be site wide in thepages that have this as an include in the code behind file.What is the bet way to do that? Any examples?Thanks Hi, You could create a base class for the code-behind classes (put every code-behind class to derive from this common base class), when changes to the base class would apply to the derived classes.Thanks,Teemu Ke...

Code-Behind versus Code-Inside and Code-Beside
Can someone explain to me how the code gets compiled when you do code-inside (like in webmatrix) as oposed to code-behind? WHen you do the code-behind I know all the code gets compiled at compile-time into a dll assembly. And I think that code-inside gets compiled at run-time. But what if you have a mixture of the two and you have a dll assembly with code-beside modules, how do they get compiled into the assembly? Maybe I'm wrong or confused, can someone clarify? I'm also aware of the Visual Studio 2005 code-beside also, will that change anything? thanks, Frank For a general...

Seperating Admin code in code-behind from general code
Hi guys, I just want to know if it would improve the functioning of my site to create two seperate dlls: One of the dll's would contain all the code for the general functioning of the site, and the other dll would contain all of the code for the administration elements of the site. Thanks GP...

How to write stored procedures and call them inside code behind or how to call them in code behind
Hi all i have to use stored procedures but i never touched these before can any body guide me what are the stored procedures and how to call them inside code behind iam using sql server 2000 as beckend database. Any Article or blog which pointing to this issue .   Best Regards Rameezwaheedlife is name of learning!Mark as an answer if it helps Hi Create stored procs http://www.asp101.com/samples/storedprocs.asp http://msdn.microsoft.com/en-us/library/aa174792.aspx Call them http://mudassarkhan.wordpress.com/2009/01/10/using-select-stored-procedures-adonet/MAKMark as Answer if...

Web resources about - what about the code-behind (code behind) - asp.net.ajax-discussion

Looking at the code behind our three uses of Apache Hadoop - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Looking at the code behind our three uses of Apache Hadoop geschrieben. Du kannst den vollständigen ...

How Heartbleed Works: The Code Behind the Internet's Security Nightmare
By now you've surely heard of Heartbleed, the hole in the internet's security that exposed countless encrypted transactions to any attacker who ...

Anatomy of an interactive: a look at the code behind our Second Screen
... and Paralympics coming to town, this presented the perfect opportunity to try it on. Being mainly responsible for the client-side code, I'll ...

How Heartbleed Works: The Code Behind the Internet's Security Nightmare
By now you've surely heard of Heartbleed, the hole in the internet's security that exposed countless encrypted transactions to any attacker who ...

Resources last updated: 1/16/2016 6:36:29 PM