【发布时间】:2015-04-01 12:07:07
【问题描述】:
将代码作为 HTML 页面运行没有问题。现在,在 Web 表单中,转换器什么也不做。试图将其从 HTML 迁移到 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>
【问题讨论】:
-
请阅读“How do I ask a good question”然后改进您的问题。
-
尝试删除
form标签并检查 -
您遇到的具体问题是什么?
-
为什么人们还在使用网络表单?这是您正在维护的遗留系统吗?
-
您应该尝试将脚本放在 MasterPage 的底部。因为首先加载 MasterPage,然后加载内容页面。
标签: javascript c# asp.net visual-studio