admin管理员组文章数量:1328406
I have this javascript
function:
function validateFile() {
var file = document.getElementById('fuCSV');
if (file.value == "") {
document.getElementById('<%=lblStatus.ClientID%>').innerhtml = "Please select a file to upload. Client!";
return false;
}
else {
document.getElementById('<%=lblStatus.ClientID%>').innerhtml = "";
return true;
}
}
Its called on the Button's OnClientClick
event like this:
<asp:Button ID="btnImport" runat="server" Text="Import" OnClientClick="return validateFile();" CausesValidation = "true"
UseSubmitBehavior ="true" OnClick="btnImport_Click" />
I'm trying to change the text of the label lblStatus
on validateFile()
method, but the text is not changing. However, while debugging...QuickWatch shows the changed value. What might be the cause for it? how can I resolve this?
I have this javascript
function:
function validateFile() {
var file = document.getElementById('fuCSV');
if (file.value == "") {
document.getElementById('<%=lblStatus.ClientID%>').innerhtml = "Please select a file to upload. Client!";
return false;
}
else {
document.getElementById('<%=lblStatus.ClientID%>').innerhtml = "";
return true;
}
}
Its called on the Button's OnClientClick
event like this:
<asp:Button ID="btnImport" runat="server" Text="Import" OnClientClick="return validateFile();" CausesValidation = "true"
UseSubmitBehavior ="true" OnClick="btnImport_Click" />
I'm trying to change the text of the label lblStatus
on validateFile()
method, but the text is not changing. However, while debugging...QuickWatch shows the changed value. What might be the cause for it? how can I resolve this?
-
3
innerhtml
is just a typo ofinnerHTML
? – Prusse Commented Oct 20, 2011 at 14:48 - did you try setting innerText as opposed to innerHTML? – Icarus Commented Oct 20, 2011 at 14:51
- @Prusse: ya...its the case problem...thanks! I have wasted lots of time to find out the cause with no luck!!! – NaveenBhat Commented Oct 20, 2011 at 14:58
4 Answers
Reset to default 3I had suggested to use innerText
but apparently, the W3C-pliant way of doing this is to use textContent:
document.getElementById('<%=lblStatus.ClientID%>').textContent = "Please select a file to upload. Client!";
See Mozilla's documentation here.
Use correct casing on the property: innerHTML
http://www.tizag./javascriptT/javascript-innerHTML.php
Javascript is case sensitive, if you set innerhtml
property instead of innerHTML
you won't see anything.
var e = document.getElementById("fName_err");
e.innerHTML = "** Enter first name";
get the id where you want to give output in e.
本文标签: aspnetJavascript change label39s text via innerhtml not workingStack Overflow
版权声明:本文标题:asp.net - Javascript change label's text via innerhtml not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742230622a2437154.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论