Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6473117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:25:40+00:00 2026-05-25T06:25:40+00:00

I followed these instructions here: http://w3schools.com/razor/razor_example.asp NOTE: I’m using Web Matrix The example said

  • 0

I followed these instructions here: http://w3schools.com/razor/razor_example.asp
NOTE: I’m using Web Matrix

The example said to do this:

@
{
var imagePath; 
if( Request["Choice"] != null)
{imagePath="images\" + Request["Choice"];} 
} 
<!DOCTYPE html> 
<html> 
<body> 
<h1>Display Images</h1> 
<form method="post" action=""> 
<div>
   I want to see: 
   <select name="Choice"> 
      <option value="Photo1.jpg">Photo 1</option> 
      <option value="Photo2.jpg">Photo 2</option> 
      <option value="Photo3.jpg">Photo 3</option> 
   </select> 
   &nbsp; 
   <input type="submit" value="Submit" /> 
</div> 
<div style="padding:10px;"> 
@if(imagePath != "")
{<img src="@imagePath" alt="Sample" />} 
</div> 
</form> 
</body> 
</html> 

And all i get this this error:

Does anything have to be setup to accept @ { being on seperate lines?

    Server Error in '/' Application.
    Parser Error 
    Description: An error occurred during the parsing of a resource
    required to service this request. Please review the following 
    specific parse error details and modify your source file appropriately. 

    Parser Error Message: A space or line break was encountered after
    the "@" character.  Only valid identifiers, keywords, comments, 
    "(" and "{" are valid at the start of a code block and they must 
    occur immediately following "@" with no space in between.


    Source Error: 


    Line 1:  @
    Line 2:  {
    Line 3:  var imagePath; 


    Source File: /Page.cshtml    Line: 1 


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 

If I put them on the same line, i get this error:

    Parser Error 
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

    Parser Error Message: The code block is missing a closing "}" character.  Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.


    Source Error: 


    Line 1:  @{
    Line 2:  var imagePath; 
    Line 3:  if( Request["Choice"] != null)


    Source File: /Page.cshtml    Line: 1

I don’t know whats wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:25:40+00:00Added an answer on May 25, 2026 at 6:25 am

    Here’s how to fix the couple of errors in your code:

    @{
        var imagePath = ""; 
        if(Request["Choice"] != null) {
            imagePath = "images/" + Request["Choice"];
        } 
    } 
    <!DOCTYPE html> 
    <html> 
    <body> 
    <h1>Display Images</h1> 
    <form method="post" action=""> 
    <div>
       I want to see: 
       <select name="Choice"> 
          <option value="Photo1.jpg">Photo 1</option> 
          <option value="Photo2.jpg">Photo 2</option> 
          <option value="Photo3.jpg">Photo 3</option> 
       </select> 
       &nbsp; 
       <input type="submit" value="Submit" /> 
    </div> 
    <div style="padding:10px;"> 
        @if(imagePath != "") {
            <img src="@imagePath" alt="Sample" />
        } 
    </div> 
    </form> 
    </body> 
    </html> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
I have followed the instructions here . To cut a long story short, I
I followed the instruction here: http://www.grails.org/doc/latest/guide/7.%20Validation.html and added into config.groovy : grails.validateable.classes = [liningtest.Warm']
<script src=http://code.jquery.com/jquery-1.4.3.js type=text/javascript></script> <script src=https://github.com/tobia/CrossSlide/raw/master/jquery.cross-slide.min.js type=text/javascript></script> <script type=text/javascript> $(function(){ $(.imagedivholder).each(function(e){ $(this).crossSlide({ speed:45, fade:1 },[
I have followed the instructions on this page to get started on ActionMailer. After
Is there a way to detect a right click followed by paste with JavaScript
I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I
Program followed by output. Someone please explain to me why 10,000,000 milliseconds from Jan
I followed the commonly-linked tip for reducing an application to the system tray :
I've followed this otherwise excellent tutorial on getting Xen working with Ubuntu but am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.