作为一个HTML页面运行代码我没有问题。现在,在一个Web表单中,转换器根本不做任何事情。正尝试将其从HTML迁移到Web表单页面以使用母版页和主题。为什么我的JavaScript不能在ASP.net web表单中工作?
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script lang="javascript" type="text/javascript">
//Convert Logic
function CelsiusConvert() {
document.converter.fahrenheit.value = (document.converter.celsius.value * 9/5) + 32
document.converter.kelvin.value = document.converter.celsius.value * 1 + 273.15
}
function FahrenheitConvert() {
document.converter.celsius.value = (document.converter.fahrenheit.value - 32) * 5/9
document.converter.kelvin.value = ((document.converter.fahrenheit.value - 32) * 5/9) + 273.15
}
function KelvinConvert() {
document.converter.celsius.value = document.converter.kelvin.value - 273.15
document.converter.fahrenheit.value = ((document.converter.kelvin.value - 273.15) * 9/5) + 32
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form name="converter">
<!--Input Fields-->
Celsius:
<input type="text" name="celsius" onchange="CelsiusConvert()"/><br />
Fahrenheit:
<input type="text" name="fahrenheit" onchange="FahrenheitConvert()"/><br />
Kelvin:
<input type="text" name="kelvin" onchange="KelvinConvert()"/><br />
<!--Convert Button-->
<input type="button" value="Convert!" />
</form>
</asp:Content>
请阅读“[我如何问一个好问题](http://stackoverflow.com/help/how-to-ask)”,然后改进你的问题。 – 2015-04-01 12:08:56
尝试移除“表格”标记并检查 – BNN 2015-04-01 12:09:17
您遇到的问题到底是什么? – Kritner 2015-04-01 12:09:23