Now if there is a value I want to populate a textbox, if no value I just want to put some default text in - But the below doesn't work? It never triggers the otherwise statement even though there is no posted value for $thedate? Any ideas where I am going wrong?
I'd check up on what is actually coming back from the umbraco.library:Request() call by inserting a
<xsl:copy-of select="$thedate" />
In the code and then running the page with and without the request variable just to check.
According to reflector the code of the library:Request call is:
public static string Request(string key)
{
if (HttpContext.Current.Request[key] != null)
{
return HttpContext.Current.Request[key];
}
return string.Empty;
}
which probably means that $thedate = '' when the key isn't present or there is no value for the request key. In all other cases it will return some kind of string content.
Checking Request For Null?
Hey everyone - Having a weird problem, I'm getting a posted value into a variable like so
<xsl:variable name="thedate" select="umbraco.library:Request('DateTo')"/>
Now if there is a value I want to populate a textbox, if no value I just want to put some default text in - But the below doesn't work? It never triggers the otherwise statement even though there is no posted value for $thedate? Any ideas where I am going wrong?
<xsl:choose> <xsl:when test="$thedate != '' or $thedate != 'Date To' or $thedate != 'NaN'"> <input class="forminput" title="Date To" id="DateTo" name="DateTo" type="text" value="{$thedate}" /> </xsl:when> <xsl:otherwise> <input class="forminput" title="Date To" id="DateTo" name="DateTo" type="text" value="Date To" /> </xsl:otherwise> </xsl:choose>
???
You could try casting to a string and then check for '' ? IIRC, it should turn NULL into an empty string
Worth a shot!
string($thedate) != ''
Hey Dan - I tried that initially and its exactly the same?? Any other ideas??
I'd check up on what is actually coming back from the umbraco.library:Request() call by inserting a
In the code and then running the page with and without the request variable just to check.
According to reflector the code of the library:Request call is:
which probably means that $thedate = '' when the key isn't present or there is no value for the request key. In all other cases it will return some kind of string content.
Regards
Jesper Hauge
is working on a reply...