0

How to call this javascript function in .aspx file in VB.net code. ANy help in this regards would be much appriciable.

$(document).ready(function() {

var numberInput = $('#A_SAtxt, #A_SStxt, #A_RAtxt, #A_CAtxt, #A_OItxt, #A_ICtxt, #A_Otxt');

numberInput.on('change', function() {
    var total = 0;

    numberInput.each(function() {
        if ($(this).val() !== '') {
            total += parseFloat($(this).val());
        }
    });

    $('#A_TAtxt').val(total);
});

});

I have even tried to do the following in the page load event but it doesn't work.

    Dim sb As New System.Text.StringBuilder()
    sb.Append("<script type = 'text/javascript'>")
    sb.Append(" $(document).ready(function() {")
    sb.Append(" var numberInput = $('#A_SAtxt, #A_SStxt, #A_RAtxt, #A_CAtxt,                 

            #A_OItxt, #A_ICtxt, #A_Otxt');")
    sb.Append("  numberInput.on('change', function() {")
    sb.Append(" var total = 0;")
    sb.Append("else{")
    sb.Append(" numberInput.each(function() {")
    sb.Append("  if ($(this).val() !== '') {")
    sb.Append("  total += parseFloat($(this).val());")
    sb.Append(" }")
    sb.Append(" });")
    sb.Append(" $('#A_TAtxt').val(total);")
    sb.Append("  });")
    sb.Append(" });​")

    sb.Append("}};</script>")
    ClientScript.RegisterClientScriptBlock(Me.GetType(), "function", sb.ToString())
user1764540
  • 67
  • 1
  • 8
  • I think the answer is here: [Call Javascript from VB.NET code behind][1] [1]: http://stackoverflow.com/questions/7673795/call-javascript-from-vb-net-code-behind – David Lloyd Brookes Nov 18 '12 at 14:43

1 Answers1

-1

Make sure you have jquery running on your computer. Or import jquery :P