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

  • SEARCH
  • Home
  • 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 7611217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:36:57+00:00 2026-05-31T01:36:57+00:00

Trying to create code section within an If condition throws error: Unexpected section keyword

  • 0

Trying to create code section within an If condition throws error:
Unexpected “section” keyword after “@” character. Once inside code, you do not need to prefix constructs like “section” with “@”.

Example 1:Create section when needed
@If bIsMobile = True Then
@section PageFooter
    <div data-role="navbar">
        <ul>
            <li><a href="#">Add</a></li>
            <li><a href="#">Edit</a></li>
            <li><a href="#">Delete</a></li>
            <li><a href="#">Search</a></li>
            <li><a href="#">Refresh</a></li>
        </ul>
    </div>
End Section
End If

Obviously we could move the condition inside the section, but this forces processing of empty section blocks:

Example 2:Creates empty section
@section PageFooter
@If bIsMobile = True Then
    <div data-role="navbar">
        <ul>
            <li><a href="#">Add</a></li>
            <li><a href="#">Edit</a></li>
            <li><a href="#">Delete</a></li>
            <li><a href="#">Search</a></li>
            <li><a href="#">Refresh</a></li>
        </ul>
    </div>
End If
End Section

How can we implement Example #1

  • 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-31T01:36:59+00:00Added an answer on May 31, 2026 at 1:36 am

    @section blocks can only appear in markup context. Thanks to SLacks for this answer.

    @If bIsMobile = True Then
    <text>
       @section PageFooter
         <div data-role="navbar">
            <ul>
                <li><a href="#">Add</a></li>
                <li><a href="#">Edit</a></li>
                <li><a href="#">Delete</a></li>
                <li><a href="#">Search</a></li>
                <li><a href="#">Refresh</a></li>
            </ul>
         </div>
       End Section
    </text>
    End If
    

    And check in _Layout page whether section is defined for non mobile pages. Otherwise it will throw an exception stating that the “PageFooter” section wasn’t defined.

    <footer>
      @If IsSectionDefined("PageFooter") Then
          RenderSection("PageFooter")
      End If
    </footer>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create the following design: This is my code so far. <section
I am trying to create CDATA section within the description field, but failing. The
I'm trying to create a piece of code but cannot get it working. The
I am trying to create an application bar in code for WinPhone7. The XAML
I am trying to create a new Element in my javascript code and append
I'm trying to create a custom drop down and using the code below it
I'm trying to create a .net charting control completely in the code behind and
I've recently been trying to create units tests for some legacy code. I've been
I'm trying to create a program that takes a text file of c++ code
I'm trying to create an application that uses the iPhone MapView (under Google Code).

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.