Coder Social home page Coder Social logo

pebsconsulting / ajax.net-professional Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michaelschwarz/ajax.net-professional

0.0 2.0 0.0 280 KB

Ajax.NET Professional (AjaxPro) for Microsoft ASP.NET

License: MIT License

C# 94.45% Batchfile 1.39% JavaScript 4.16%

ajax.net-professional's Introduction

Ajax.NET Professional

Ajax.NET Professional (AjaxPro) is one of the first AJAX frameworks available for Microsoft ASP.NET.

The framework will create proxy JavaScript classes that are used on client-side to invoke methods on the web server with full data type support working on all common web browsers including mobile devices. Return your own classes, structures, DataSets, enums,... as you are doing directly in .NET.

Quick Guide

  • Download the latest Ajax.NET Professional
  • Add a reference to the AjaxPro.2.dll (for the .NET 1.1 Framework use AjaxPro.dll)
  • Add following lines to your web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <httpHandlers>
      <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
    </httpHandlers>
    [...]
  </system.web>
</configuration>
  • Now, you have to mark your .NET methods with an AjaxMethod attribute
[AjaxPro.AjaxMethod]
public DateTime GetServerTime()
{
  return DateTime.Now;
}
  • To use the .NET method on the client-side JavaScript you have to register the methods, this will be done to register a complete class to Ajax.NET
namespace MyDemo
{
  public class DefaultWebPage
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      AjaxPro.Utility.RegisterTypeForAjax(typeof(DefaultWebPage));
    }

    [AjaxPro.AjaxMethod]
    public static DateTime GetServerTime()
    {
      return DateTime.Now;
    }
  }
}
  • If you start the web page two JavaScript includes are rendered to the HTML source
  • To call a .NET method form the client-side JavaScript code you can use following syntax
function getServerTime() {
  MyDemo.DefaultWebPage.GetServerTime(getServerTime_callback);  // asynchronous call
}

// This method will be called after the method has been executed
// and the result has been sent to the client.
function getServerTime_callback(res) {
  alert(res.value);
}

ajax.net-professional's People

Contributors

maraymer avatar michaelschwarz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.