I have the following label control:
<asp:Label ForeColor="DarkGreen" runat="server" ID="lblStatus"></asp:Label>
Its value is populated with the Page_Load event.
I attached the following Javascript (placed at the end of the page , not the main page):
function Validate() { var lblObj = document.getElementById('<%=lblStatus.ClientID%>'); alert(lblObj.value); if (lblObj.value == "Replaced" || lblObj.value == 'Trashed' || lblObj.value == "Internal Use") { alert("Products with" + lblObj.value + "status cannot be reserved"); return false; } }
The message (lblObj.value) displays a pop-up window with the text "undefined". How can I fix this problem? Please, I tried many combinations to host JavaScript, but no luck! Thanks
UPDATE
Browser code:
<span id="ctl00__main_lblStatus" style="color:DarkGreen;">Available</span></td>
The first line of the Validate JS function:
function Validate() { var lblObj = document.getElementById('ctl00__main_lblStatus');
source share