简体   繁体   中英

is there a way to access javascript variable in code behind?

here's my code

function qtyblur() {
    var textgettaxbaseid = document.getElementById("txttaxbase");
    var textgettaxbasevalue = textgettaxbaseid.value;
    var taxbase = parseFloat(textgetsubtotalid.value / 1.12).toFixed(2);
    textgettaxbaseid.value = taxbase;
}

I want to access my variables here and use it in my code behind. I am really new to this so bear with me.

To access what you have in client side (javascript) in code bahind you need to send a call to server. You call post the form or send an ajax call on server.

Usually we put the javascript variable values in some hidden field and get the hidden field in code behind and extract the values of javascript.

no you cannot. Instead, use a Hidden Field in you javascript function, assign a variable's value to it and use the Hidden Field in your code behind.

在代码隐藏中使用Web方法,并使用jquery和json将javascript变量传递给Web方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM