There might be something obvious I'm missing, but I can't seem to make my Javascript evaluate to 'true' and fire the event I want (setting a checkbox to ticked if the value is true/a string equivalent of true).
Code as follows:
window.onload = function () {
alert("let's go!");
var enabledVal = TempData["enabled"];
if (enabledVal == "checked") {
alert("made it here");
document.getElementById("eCheck").checked = true;
}
}
I know the onload function is being reached because the alert fires. The TempData["enabled"] is set in the controller as follows:
//returns True/False
string enabledVal = (from person in testTechObj.People
where person.PersonId.Equals(id)
select person.IsEnabled).SingleOrDefault().ToString();
if (enabledVal == "True")
{
enabledVal = "checked";
}
...
//pass enabled/authorised values
TempData["enabled"] = enabledVal;
I tried checking for both a boolean and a string, but the If statement doesn't evaluate in either case. I know TempData["enabled"] is set to what I'd expect (either "checked" or "True") as I tried writing it out to the screen with @TempData["enabled"] and the values I expected appeared.
Is there something obvious I'm missing?
EDIT: Browser output (third bit of text from the top is @TempData["enabled"]
[
]1
True(a Boolean)?