Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > BOOK: Professional ASP.NET MVC 5
BOOK: Professional ASP.NET MVC 5
This is the forum to discuss the Wrox book Professional ASP.NET MVC 5 by Jon Galloway, Brad Wilson, K. Scott Allen, David Matson; ISBN: 978-1-118-79475-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 29th, 2014, 04:43 PM
Authorized User
Join Date: Nov 2013
Posts: 84
Thanks: 29
Thanked 2 Times in 2 Posts
Default In MVC 5 (VB) why is the '@' required in front of basic html tags?

This code will not work without the @ in front of the <li> tag.

@For Each A In ViewBag.stuff  (where stuff is a list of strings)
Is there an easy rule to remember to know when the @ is required to transition back to html? In the Razor section of Chapter 3 it indicates @ is required to transition from markup to code, and sometimes back, but I never found any examples or explanations about when @ is required for the transition back to markup.


Best Regards,
Old September 2nd, 2014, 04:49 PM
Authorized User
Join Date: Nov 2013
Posts: 84
Thanks: 29
Thanked 2 Times in 2 Posts
Default Self posted answer

From Stack Overflow:

It is required when the previous line is plain code (such as For Each).

This is because in VB there are XML literals that create ambiguity.

The Following User Says Thank You to AlanWheeler For This Useful Post:
rfalanga (November 5th, 2014)
Old September 15th, 2014, 04:23 AM
Wrox Author
Join Date: Oct 2006
Posts: 36
Thanks: 1
Thanked 5 Times in 5 Posts

Thanks for posting the update - all the code samples in the book are in C#, and I honestly haven't written much VB.NET for several years (although it was my first .NET language) so I'd have been looking over on SO myself. Of course, seeing the answer makes total sense.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot parse html tags toskers XSLT 3 June 13th, 2012 01:07 AM
HTML tags issue.. atulshin XSLT 2 October 21st, 2008 03:57 AM
Render HTML tags jacksprophet XSLT 1 December 28th, 2006 07:03 PM
remove html tags lucian Dreamweaver (all versions) 1 November 14th, 2004 03:25 PM
Eliminating HTML TAGs beyondforsaken VB How-To 12 June 12th, 2003 08:00 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.