从javascript函数调用来自***。aspx.cs的函数 [英] call function from ***.aspx.cs from javascript function
问题描述
你好,
我有以下的HTML代码:
Hello,
I have the folowing html code :
<select name="myselect" id="myselect" >
<option value="2">3 luni - pret = 15$</option>
<option value="4">6 luni - pret = 30$</option>
<option value="6">1 an - pret = 60$</option>
<option value="8">5 ani - pret = 250$</option>
<option value="10">PeViata - pret = 500$</option>
</select>
每次项目更改时我想要从我的aspx.cs文件中调用一个函数。
我真的不知道该怎么做(这是我使用asp.net的第一个应用程序)。
我以为我可以在项目更改时调用js函数。下面是我的js功能。
Each time when the item changes I want to call a function from my aspx.cs file.
I really don't know how to do this (this is my first app using asp.net) .
I thought that I could call a js function when the item is changed . below is my js function.
function selectorFunction() {
var x = document.getElementById("myselect").value;
<% selectPrice(Convert.ToInt32(x)); %>
}
此函数的问题是var x不存在于那个背景。
当你选择了不同的项目时,能不能帮我弄清楚如何从我的aspx.cs文件中调用一个函数。
提前谢谢。
The issue with this function is that var x does not exists in that context.
Can you please help me figure out how can I call a function from my aspx.cs file when a different item is selected.
Thank you in advance.
推荐答案
< / option >
< 选项 值 = 4 > 6 luni - pret = 30
</option> <option value="4">6 luni - pret = 30
< span class =code-keyword>< / option >
< 选项 value = 6 > 1 an - pret = 60
</option> <option value="6">1 an - pret = 60
< / option >
< 选项 value = 8 < span class =code-keyword>> 5 ani - pret = 250
</option> <option value="8">5 ani - pret = 250
这篇关于从javascript函数调用来自***。aspx.cs的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!