I have a piece of javascript code evaluated at runtime, with the <%= %> syntax...
Now, inside the <%= %>, instead of a hard coded string, i'd like to have the value stored in a variable... How can I do this?
This is the function:
function updateDescriptionLabel(msgToParse, dataColumn, TextBoxID) {
    var myData = JSON.parse(msgToParse.d);
    alert(msgToParse);
    alert(dataColumn);
    alert(TextBoxID);
    // this is the explicit call, it's ok
    $('#' + '<%= this.TextBoxDES_MACCHINA.ClientID  %>').val($.trim(myData["DescrMacchina"]));
    // NOW i want to make the call by using the variable value
    var txtDes = TextBoxID;
    $('#' + '<%= this.' + txtDes.toString() + '.ClientID %>').val($.trim(myData["DescrMacch"]));
    // BUT i get the error: Too many characters in character literal
}
============== EDIT ===============
I have a bunch of TextBoxID that, on lost focus, get a get a value from database, and display it on the appropriate TextBoxDESCRIPTION related to the ID... But I have to duplicate the code for each TextBox, so I'd like to generalize it...
I post the entire code.
 <script language="javascript" type="text/javascript">
    /* ==> JSON  */
    //Ajax Request
    function SendAjaxRequest(urlMethod, jsonData, returnFunction) {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: urlMethod,
            data: jsonData,
            dataType: "json",
            success: function (msg) {
                // Do something interesting here.
                if (msg != null) {
                    returnFunction(msg);
                }
            },
            error: function (xhr, status, error) {
                // Boil the ASP.NET AJAX error down to JSON.
                var err = eval("(" + xhr.responseText + ")");
                // Display the specific error raised by the server
                alert(err.Message);
            }
        });
    }
    // I'd like to generalize it ...
    function SendComplexAjaxRequest(urlMethod, jsonData, returnFunction, dataColumn, TextBoxID) {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: urlMethod,
            data: jsonData,
            dataType: "json",
            success: function (msg) {
                // Do something interesting here.
                if (msg != null) {
                    returnFunction(msg, dataColumn, TextBoxID);
                }
            },
            error: function (xhr, status, error) {
                // Boil the ASP.NET AJAX error down to JSON.
                var err = eval("(" + xhr.responseText + ")");
                // Display the specific error raised by the server
                alert(err.Message);
            }
        });
    }
// ONE function for each textBox
    function callUpdateGuastoAttributes(code) {
        var urlMethod = '<% = ResolveClientUrl("~/Services/ws_Attributes.asmx/OdLGetMacchinaAttributes") %>';
        var jsonData = "{'COD_MACCHINA':'" + code + "'}";
        var successFunction = updateLabelsGuastoAttributs;
        SendAjaxRequest(urlMethod, jsonData, successFunction);
    }
    function callUpdateCausaGuastoAttributes(code) {
        var urlMethod = '<% = ResolveClientUrl("~/Services/ws_Attributes.asmx/OdLGetMacchinaAttributes") %>';
        var jsonData = "{'COD_MACCHINA':'" + code + "'}";
        var successFunction = updateLabelsCausaGuastoAttributs;
        SendAjaxRequest(urlMethod, jsonData, successFunction);
    }
// I can have only one function:
    function callUpdateMacchinaAttributes(code) {
        var urlMethod = '<% = ResolveClientUrl("~/Services/ws_Attributes.asmx/OdLGetMacchinaAttributes") %>';
        var jsonData = "{'COD_MACCHINA':'" + code + "'}";
        var successFunction = updateDescriptionLabel;
        SendComplexAjaxRequest(urlMethod, jsonData, successFunction, 'DescrMacchina', 'TextBoxDES_MACCHINA');
    }
    /* <== CALLBACK  */
function updateLabelsMacchinaAttributs(msg) {
        var myData = JSON.parse(msg.d);
        $('#' + '<%= this.TextBoxDES_MACCHINA.ClientID  %>').val($.trim(myData["DescrMacchina"]));
    }
    function updateLabelsGuastoAttributs(msg) {
        var myData = JSON.parse(msg.d);
        $('#' + '<%= this.TextBoxDES_GUASTO.ClientID  %>').val($.trim(myData["description"]));
    }
    function updateLabelsCausaGuastoAttributs(msg) {
        var myData = JSON.parse(msg.d);
        $('#' + '<%= this.TextBoxDES_CAUSA_GUASTO.ClientID  %>').val($.trim(myData["description"]));
    }
// BUT I have to generalize it...
function updateDescriptionLabel(msgToParse, dataColumn, TextBoxID) {
        var myData = JSON.parse(msgToParse.d);
        alert(msgToParse);
        alert(dataColumn);
        alert(TextBoxID);
        // this is the explicit call
        $('#' + '<%= this.TextBoxDES_MACCHINA.ClientID  %>').val($.trim(myData["DescrMacchina"]));
        // i want to make the call by using the variables values
        var dCol = dataColumn;
        var txtDes = TextBoxID;
        $('#' + '<%= this.' + txtDes.toString() + '.ClientID %>').val($.trim(myData[dCol]));
        // i get the error: Too many characters in character literal
    }
 
    