Archive | Work with ASP.NET AJAX RSS for this section

ASP.NET AJAX Application Services

In this post, we’ll examine the built-in services in ASP.NET AJAX. You call these services in a same way as you’d call any custom web service from script, but there are some differences.

There are three built-in services in ASP.NET AJAX, namely:

  • Authentication service
  • Role service
  • Profile service

To use these services, you must take two steps: first, configure that you’d like to call these services in your web.config file, then call the configured services from script in your pages. Both the configuration and the calling code is different for the three services, so lets get started with authentication.
Read More…

Create and Register Client Script

There are three ways of defining a client script on an ASP.NET Web page:

  • Define a script block on your page
  • Use the ClientScriptManager class to dynamically add JavaScript at run time
  • Use the ScriptManager server control to register JavaScript

Now let’s look deeper into the details. The first method of defining scripts is the traditional method. It has nothing to do with ASP.NET, so you can embed your scripts like this into simple HTML pages or PHP as well. You should add a script tag anywhere on your page (the head section is the most preferred) and define your JavaScript there, like this:

<script type=”text/javascript”>

    function myFunc() {

        //do something

    }

</script>

Read More…

Implement Web Forms by using ASP.NET AJAX

Using ASP.NET AJAX provides the following benefits:

  • Improved efficiency, since a massive amount of processing occurs in the browser
  • Familiar UI elements
  • Partial-page rendering
  • Client integration of ASP.NET services, such as authentication, roles, profiles
  • Auto-generated proxy classes for web services called from client script
  • Extendible controls with client functionality
  • Browser compatibility

 
Read More…

Calling Web Services from Client Script

Web services can be called from client scripts, such as Javascript too. This is most useful for example if you need to expose a database result set to your javascipt client code. Both XML Web services and WCF services can be called from client script. The steps are essentially the same for both scenarios.

First you must expose your service to be consumable from client script. For a standard XML Web service, add the ScriptServiceAttribute to your .asmx.cs file. If you work from template, you just need to uncomment the line. Your result would look like this:

ScriptService1

To set up a WCF service, you should ensure of the following:

  1. The service must be hosted by a web application within a .svc file. You will need to point to this file later.
  2. You must configure the web application to support service calls from client script.

Read More…