Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > BOOK: Professional ASP.NET MVC 5
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 29th, 2014, 04:43 PM
Authorized User
Points: 416, Level: 7
Points: 416, Level: 7 Points: 416, Level: 7 Points: 416, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.

Code:
@For Each A In ViewBag.stuff  (where stuff is a list of strings)
  @<li>@A</li>
Next
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.

Thanks.

Best Regards,
Alan
Reply With Quote
  #2 (permalink)  
Old September 2nd, 2014, 04:49 PM
Authorized User
Points: 416, Level: 7
Points: 416, Level: 7 Points: 416, Level: 7 Points: 416, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.

aw
Reply With Quote
The Following User Says Thank You to AlanWheeler For This Useful Post:
rfalanga (November 5th, 2014)
  #3 (permalink)  
Old September 15th, 2014, 04:23 AM
Wrox Author
Points: 165, Level: 3
Points: 165, Level: 3 Points: 165, Level: 3 Points: 165, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: San Diego, CA, USA
Posts: 36
Thanks: 1
Thanked 5 Times in 5 Posts
Default

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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:50 AM.


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