0

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
  • 3
    innerhtml is just a typo of innerHTML? Commented Oct 20, 2011 at 14:48
  • did you try setting innerText as opposed to innerHTML? 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!!! Commented Oct 20, 2011 at 14:58

4 Answers 4

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Interesting, I didn't know about textContent
1

Use correct casing on the property: innerHTML

http://www.tizag.com/javascriptT/javascript-innerHTML.php

Comments

1

Javascript is case sensitive, if you set innerhtml property instead of innerHTML you won't see anything.

Comments

0
var e = document.getElementById("fName_err");
e.innerHTML = "** Enter first name";

get the id where you want to give output in e.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.