I thought I had the correct syntax for this ternary operator to check for an empty parameter, but as it is the value that I have for the defaults always override the parameter value. What have I done wrong?
var StartLevel = String.IsNullOrEmpty(Parameter.startLevel) ? 4 : int.Parse(Parameter.startLevel);
var FinishLevel = String.IsNullOrEmpty(Parameter.finishLevel) ? 6 : int.Parse(Parameter.finishLevel);
Ternary Operator Check for String.IsNullOrEmpty
I thought I had the correct syntax for this ternary operator to check for an empty parameter, but as it is the value that I have for the defaults always override the parameter value. What have I done wrong?
var StartLevel = String.IsNullOrEmpty(Parameter.startLevel) ? 4 : int.Parse(Parameter.startLevel);
var FinishLevel = String.IsNullOrEmpty(Parameter.finishLevel) ? 6 : int.Parse(Parameter.finishLevel);
There is nothing wrong with this. Are you sure that
Parameter.startLevel
is the correct parameter alias and has a value?Yes, here is the macro on the template. It won't go to level 7 unless I change the defalut in the ternary to 7.
<umbraco:Macro Alias="Category2LeftNavigation" runat="server" startLevel="4" finishLevel="7"></umbraco:Macro>
Here is my navigation Razor.
Have you configured the parameter in the macro within the Umbraco UI also?
Crud!! That was it! I thought for sure that I had added those to the macro. Sorry to waste your time Jeavon. Thanks for your help!
No worries, I have certainly been there!
is working on a reply...