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 7029061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:29:20+00:00 2026-05-28T00:29:20+00:00

This is the Code I’m having problems with: @{int i = 1;} @foreach (var

  • 0

This is the Code I’m having problems with:

@{int i = 1;}
@foreach (var item in Model)
{
    @:<ul id="sortablei" class='droptrue'>
    i++;
}

How can I use i in the id sortablei?
I tried: @i or @{i} but it seems without a space before the i its not working.
I couldn’t find an answer to my problem in the Razor Syntax Reference so I’m a bit clueless right now.

  • 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-28T00:29:21+00:00Added an answer on May 28, 2026 at 12:29 am

    Brackets:

    @:<ul id="sortable@(i)" class='droptrue'>
    

    The brackets here scope the razor expression; in many cases they aren’t required, however they are necessary when:

    • the expression (on the right) is non-trivial (spaces. etc) and needs help to scope it
    • where without it, it looks like an email address, i.e. abc@def – this has special handling to avoid breaking pages with email addresses in them
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code builds without problems but fails when executed: var query = _db.STEWARDSHIP .OrderByDescending(r
This code works (C# 3) double d; if(d == (double)(int)d) ...; Is there a
This code can be used to select the first ten records from a table
This code works: $(contentDiv).fadeIn(slow); This does not: var elementName = 'contentDiv'; $(elementName).fadeIn(slow); No fade
This code fails to compile: namespace boost { template<class T> class scoped_ptr; } namespace
This code does not compile. public class Diamond { public static void diamondOfAsterisks(String *
This code sampler is used to learn MPI programming. The MPI package I use
This code: #include Backpack.h #include <sstream> #include <algorithm> int Backpack::getCurrentWeight() { int weight =
This code can change color of a UINavigationBar everywhere within the application. However, I
This code: var app = require('express').createServer(); var ejs = require('ejs'); var fs = require('fs');

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.