What is wrong with this piece of code? I get this error: d:\web\localuser\zicon.dk\contour\macroScripts\635164008321083221_loop.cshtml(27): error CS1026: ) expected
@for(var i =1; i < 5; i++) { if(Model.HasValue("item" + i)){
var dateItem = @Model.GetPropertyValue("date" + i); var postDate = umbraco.library.FormatDateTime(dateItem.ToString(), "dd/MM/yyyy"); var tester = umbraco.library.DateGreaterThanOrEqualToday(@dateItem);
if (1 < 2){ <p>jjj</p> } <p>I am @tester </p> <p>@Model.GetPropertyValue("item" + i) og @postDate</p>
}
}
it works fine if I dont have the if(1<2){}
What I want to do is to say if(@tester == true){ "Do this" }
Maybe it'smyvariablesis wrong with. Because if I move the variables outside ofthe firstif-statementi also get an error: c:\aspnettemp\v4.0.30319\x86\root\c379af71\9e87e254\App_Web_635164006886192701_loop.cshtml.70df5e80.emdpysem.0.cs(111):
error CS1513: } expected
Hmm, now this works, but only if I have the <p> tag in line 6. Without that line it gives me an error. Does anyone havean explanation?
Is there something wrong in the vay I write the variables?
@for(var i =1; i < 5; i++) { var fff = @Model.GetPropertyValue("date" + i); var postDate = umbraco.library.FormatDateTime(fff.ToString(), "dd/MM/yyyy"); var tester = umbraco.library.DateGreaterThanOrEqualToday(@fff); <p>vv</p>
if(Model.HasValue("item" + i)){ <p>I am @tester </p> <p>@Model.GetPropertyValue("item" + i) og @postDate</p> if(@tester == false){ <p>hej</p> } }
error in my if-statement
What is wrong with this piece of code? I get this error:
d:\web\localuser\zicon.dk\contour\macroScripts\635164008321083221_loop.cshtml(27): error CS1026: ) expected
it works fine if I dont have the if(1<2){}
What I want to do is to say if(@tester == true){
"Do this"
}
Maybe it's my variables is wrong with. Because if I move the variables outside of the first if-statement i also get an error:
c:\aspnettemp\v4.0.30319\x86\root\c379af71\9e87e254\App_Web_635164006886192701_loop.cshtml.70df5e80.emdpysem.0.cs(111): error CS1513: } expected
Hi Kate,
Try to write the tester variable like this and see if it´s solve your problem:
/Dennis
Nope, sorry it did not help :-)
Hmm, now this works, but only if I have the <p> tag in line 6. Without that line it gives me an error.
Does anyone have an explanation?
Is there something wrong in the vay I write the variables?
Hi Kate,
I cant see a specific syntax issue but you did have a few unnecessary @ that can cause problems, give this a try
Jeavon
It works perfectly :-)
I have not quite figured out what the rule is for when to use @ or leave it out :-)
Thanks for your help
Hi Kate,
Try to see if you could use my first and last post in this topic.
http://our.umbraco.org/forum/developers/razor/45137-What-is-@Model
/Dennis
is working on a reply...