Send Data From JavaScript to C# Server Code

This post describes how to send data from a JavaScript client to a C# handler on the server. The article will guide you through the development of small ASP.NET application that enables to send a JSON Data from a HTML page to a C# server code handler.

This assumes that you are an intermediate developer with some basic knowledge in C# and ASP.NET.


First, open Visual Studio then choose C# > Web > ASP.NET application then select Empty.

If using Visual Studio 2013, it will generate an empty ASP.NET project for you.

Add a new HTML and paste the following code:

<label id="From" />How to send Data from JavaScript to C# Handler<br />
            <td><label id="From"/>From : </td>
            <td><input id="TxtFrom"></td>
            <td><label id="To"/>To : </td>
            <td><input id="TxtTo" required="required"></td>
            <td><label id="To" />Body : </td>
            <td><textarea id="TxtBody" required="required" 
            rows="10" cols="30"></textarea></td>
            <td style="align-content:flex-end">
                <button onclick="loadJsonData();">Send Data to the Server</button>

Read the rest of the code here:

Leave a Reply

Your email address will not be published. Required fields are marked *