Skip to content

Show json result in Textbox ASP.Net

I want to know that how can I get the following json result in textbox instead console.log in C# ?


        var apikey = {

            request('GET', '' + apikey.key).then((r1) => {
                var x1 = JSON.parse(;

        function request(method, url)
            return new Promise(function (resolve, reject) {
                var xhr = new XMLHttpRequest();
      , url);
                xhr.onload = resolve;
                xhr.onerror = reject;

Thx everyone


Try this:

document.getElementById('textboxId').value =;

you can have:

<asp:TextBox ID="textboxId" runat="server"></asp:TextBox>

Sometimes your js code could be executed before the rendering of the page has been completed, so it is better to add the js to the end of the body, or use jquery to wait the completion of the rendering phase.

$(document).ready(function() {
   document.getElementById('<%=textboxId.ClientID %>').value =;