0

I have this asp control in my asp page:

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlace" runat="server">
    <asp:HiddenField ID="colorBuffer" runat="server" />
</asp:Content>

I use this function to access asp control abouve:

window.onload = function () {
    var elem = document.getElementById("colorBuffer");
}

But elem is always null.Any idea why?I think that some changes made to the name of ID hidden field by ASP.

1
  • Did you check what html is generated? Commented Feb 24, 2016 at 9:13

2 Answers 2

3

var elem = document.getElementById('<%=colorBuffer.ClientID%>');

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

Comments

1
document.querySelector('[id^="colorBuffer"]').id;

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.