Reputation: 3318
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?
Upvotes: 0
Views: 11193
Reputation: 1
var e = document.getElementById("fName_err");
e.innerHTML = "** Enter first name";
get the id where you want to give output in e.
Upvotes: 0
Reputation: 63956
I had suggested to use innerText
but apparently, the W3C-compliant 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.
Upvotes: 3
Reputation: 8166
Javascript is case sensitive, if you set innerhtml
property instead of innerHTML
you won't see anything.
Upvotes: 1
Reputation: 3524
Use correct casing on the property: innerHTML
http://www.tizag.com/javascriptT/javascript-innerHTML.php
Upvotes: 1