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 />
    <table>
        <tr>
            <td><label id="From"/>From : </td>
            <td><input id="TxtFrom"></td>
        </tr>
        <tr>
            <td><label id="To"/>To : </td>
            <td><input id="TxtTo" required="required"></td>
        </tr>
        <tr>
            <td><label id="To" />Body : </td>
            <td><textarea id="TxtBody" required="required" 
            rows="10" cols="30"></textarea></td>
        </tr>
        <tr>
            <td/>
            <td style="align-content:flex-end">
                <button onclick="loadJsonData();">Send Data to the Server</button>
            </td>
        </tr>
</table>


Read the rest of the code here: http://www.codeproject.com/Tips/832696/How-to-send-Data-from-JavaScript-to-Csharp-Server

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Email
Print