{"id":119,"date":"2013-06-18T17:18:43","date_gmt":"2013-06-18T17:18:43","guid":{"rendered":"https:\/\/www.joetannorella.com\/?p=119"},"modified":"2014-11-24T18:29:50","modified_gmt":"2014-11-24T18:29:50","slug":"some-net-bits-i-need-to-remember","status":"publish","type":"post","link":"https:\/\/www.joetannorella.com\/some-net-bits-i-need-to-remember\/","title":{"rendered":"Some .NET snippets that I need to remember"},"content":{"rendered":"
So I’m developing some front-end stuff in using .NET. Coming from a PHP, I find some of the conventions and features of .NET to be quite confusing. I’m going to update this post with some snippets I’ll likely need to use in the future:<\/p>\n
Controller code example<\/strong><\/p>\n ViewData[“SectionParent”] = “Affiliate”;<\/p>\n View code example<\/strong><\/p>\n <\/p>\n This bit really confused me. I was trying to evaluate ViewData, where if it’s true, output some divs. It worked absolutely fine:<\/p>\n However, doing the exact same thing with only text (no HTML markup) kept throwing an error:<\/p>\n The solution is to wrap the plain text in <text><\/text> tags, and voila, it works just fine :-):<\/p>\n More coming soon!<\/p>\n","protected":false},"excerpt":{"rendered":" So I’m developing some front-end stuff in using .NET. Coming from a PHP, I find some of the conventions and features of .NET to be quite confusing. I’m going to update this post with some snippets I’ll likely need to use in the future: How to easily evaluate data from controller in a view Controller…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"yoast_head":"\n@if (ViewData[\"SectionParent\"] == \"Affiliate\") { \/\/ code here \/\/ }<\/code><\/p>\n
How to output plain text in a view @if statement<\/h3>\n
@if (ViewData[\"SectionParent\"] == \"Affiliate\") { <div>Bla bla content and more divs<\/div> }<\/code><\/p>\n
@if (ViewData[\"SectionParent\"] == \"Affiliate\") { Some text here }<\/code><\/p>\n
@if (ViewData[\"SectionParent\"] == \"Affiliate\") { <text>Some text here<\/text> }<\/code><\/p>\n
Misc<\/h3>\n