Created
August 10, 2011 18:32
-
-
Save greystate/1137721 to your computer and use it in GitHub Desktop.
Raz0r kerfluffle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@helper RenderCountryOptions() { | |
<option>Choose a country...</option> | |
@foreach(var region in @Model.XPath("/root/Website/CountryList/CountryList[Country[not(active = 0)]]")) | |
{ | |
<optgroup label="@region.Name"> | |
@foreach(var country in @region.Children) | |
{ | |
<option>@country.Name</option> | |
} | |
</optgroup> | |
} | |
} | |
// This one says: | |
// Unexpected "foreach" keyword after "@" character. Once inside code, you do not need to prefix constructs like "foreach" with "@". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@helper RenderCountryOptions() { | |
<option>Choose a country...</option> | |
foreach(var region in @Model.XPath("/root/Website/CountryList/CountryList[Country[not(active = 0)]]")) | |
{ | |
<optgroup label="@region.Name"> | |
foreach(var country in @region.Children) | |
{ | |
<option>@country.Name</option> | |
} | |
</optgroup> | |
} | |
} | |
// The name 'country' does not exist in the current context |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@helper RenderCountryOptions() { | |
<option>Choose a country...</option> | |
foreach(var region in @Model.XPath("/root/Website/CountryList/CountryList[Country[not(active = 0)]]")) | |
{ | |
<optgroup label="@region.Name"> | |
@foreach(var country in @region.Children) | |
{ | |
<option>@country.Name</option> | |
} | |
</optgroup> | |
} | |
} | |
// Hmmm... yes. OK - I get that, but it's weird for me... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment