I have created a JavaScript function to get the type of html control and set it to specified value.
function SetControlValue(ctrl, value) {
if (value == undefined)
return "";
if (document.getElementById(ctrl).type == "text") {
document.getElementById(ctrl).value = value;
}
else if (document.getElementById(ctrl).type == "label") {
//document.getElementById(ctrl).innerText = value;
document.getElementById(ctrl).innerHTML = value;
}
return false;
}
On my ASPX page i have created a label as below
<asp:Label id="lblMessage" class="labels"Font-Size="Medium" runat="server"></asp:Label>
and now calling the function
var don="sample text";
SetControlValue('lblMessage', don)
My question is why SetControlValue() function working on text fields but does not work on labels. Is there something that am missing? Thanks.