У меня есть следующие коды ASP. NET, javascript:
var decPts = <%=currentDec.Survey.User.DecPts %>;
var locn = <%=currentDec.Survey.User.Location %>;
function sDPts(dn) {
return ((Math.round(dn * Math.pow(10, decPts)) / Math.pow(10,
decPts)).toFixed(decPts));
}
function update(decNumber) {
dojo.byId('debug1').innerHTML = "decPts = (" + decPts + ")";
dojo.byId('debug2').innerHTML = "Location = (" + locn + ")";
}
<asp:content>
<div id="debug1"></div>
<div id="debug2"></div>
</content>
Я получаю следующее:
decPts = (2) ---- correct
Location = (undefined) ---- not correct
DecPts и Location столбцы в записи базы данных SQL. DecPts - это int, а Location - строка
Если я перепишу HTML как
<div id="debug1"></div></td>
<div id="debug2"><%=currentDec.Survey.User.Location %></div>
, я получу правильный ответ, т.е.
decPts = (2)
US
Что я делаю неправильно?