//CHECK IF WE SHOULD SHOW THE PASSWORD HINT OR NOT
Setting passwordhints;
using (var db = new dbDataContext())
{
passwordhints = (from c in db.Settings
where c.Name == "ShowPasswordHints" && c.ID == _ID
select c).FirstOrDefault();
}
if (passwordhints != null)
//NOTE: .Value IS A STRING
ViewData["ShowPasswordHints"] = passwordhints.Value;
else
ViewData["ShowPasswordHints"] = "False";
//END PASSWORD HINTS CHECK
is in the controller, when I get to the page itself I output
<%=ViewData["ShowPasswordHints"]%>
into the title tag and I can see it up there it says "True" (without quotes, I also checked for spaces by surrounding it with parenthesis and there are no spaces it is literally just True)
However when I do
<%if(ViewData["ShowPasswordHints"] == "True") {%> SHOW THIS <%}%>
SHOW THIS never appears, what the hell?
UPDATE: However, if ViewData is set like this... IT WORKS... HUH??
if (accountRepository.isLDAPEnabled(_ID))
ViewData["LDAP"] = "True";
else
ViewData["LDAP"] = "False";
view...
<%if(ViewData["LDAP"] == "True"){ %>
SHOW THIS
<%} %>
THANKS EVERYONE, HERE IS NEW METHOD THAT IS WORKING GREAT
ViewData["something"] = true;
<%if(true.Equals(ViewData["something"])){%> SHOW THIS <%}%>
"True".Equals(ViewData["ShowPasswordHints"])
. No ClassCastException if the object in the view data dictionary is not a string. – Robbierobbin