Why would =ViewData[“”] show a string but evaluating it for the same string fail?

//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 <%}%>
5
задан Josh Lee 7 December 2010 в 05:26
поделиться