# How to implement AJAX to call .NET code-behind methods

**URL:** <https://discuss.workflowgen.com/t/how-to-implement-ajax-to-call-net-code-behind-methods/230>\
**Category:** Visual Studio Web Forms\
**Created:** [May 26, 2016, 2:02am UTC](https://discuss.workflowgen.com/t/how-to-implement-ajax-to-call-net-code-behind-methods/230 "2016-05-26T02:02:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wfg-admin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/wfg-admin/32/714_2.png) [@wfg-admin](https://discuss.workflowgen.com/u/wfg-admin)\
**Post date:** [May 26, 2016, 2:02am UTC](https://discuss.workflowgen.com/t/how-to-implement-ajax-to-call-net-code-behind-methods/230/1 "2016-05-26T02:02:29Z")

</div>

You can implement AJAX to call .NET code-behind methods. This solution allows you to create client-side JavaScript functions that retrieve data from the server via .NET web methods managed in the web form’s code-behind. To do this:

1. Enable AJAX on the **General** tab in **Form configuration** panel.

2. In the code-behind `Page_Load` method, set the `EnablePageMethod` property of the script manager to `true`. The `ScriptManager1` object is automatically added to the form’s auto-generated ASPX file when AJAX is enabled.

3. Store the current culture information in a variable to be able to use it later in the static web method:

4. Create and annotate your web method in code-behind. The advantage of using string parameters in a web method is that you can pass values in any format that come from the client side without having to worry about globalization.

5. On the **Web References** tab in the **Form configuration** panel, create a function to call your web method:

6. Add the JavaScript event where you need it in your form. For example, to calculate the updated value of a textbox, you would add the `onchange` custom attribute to the textbox with the value `doCalculate();`.
