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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:23:51+00:00 2026-06-05T20:23:51+00:00

In the MVC View code below, isLoggedInDb is underlined in green with a tooltip

  • 0

In the MVC View code below, isLoggedInDb is underlined in green with a tooltip displaying Expected ‘;’. There clearly is a ;, and it is hard to Google for ; on top of it. I’ve seen that others have problems creating JavaScript serverside in this manner, so maybe it’s not best practice. Should this be ignored, or is there a legitimate reason for Intellisense to complain?

@* SHTML Code Above *@

<script type="text/javascript">
    @{  
        string isLoggedInDb;

        if(Session["isLoggedInDb"] != null)
        {
            if(Session["isLoggedInDb"].ToString() == "1") 
            {
                isLoggedInDb = "1";
            }
            else
            {
                isLoggedInDb = "0";
            }
        }
    }

    var dblogin=@(isLoggedInDb);

    @*....etc*@

    }

Edit:

It just occurred to me that building JavaScript programatically, probably is not the best idea, since it might be considered best practice to keep JavaScript in separate files, which are often cached. I think I should program hidden variables in the HTML that JavaScript reads instead. Maybe someone can confirm this.

  • 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-06-05T20:23:52+00:00Added an answer on June 5, 2026 at 8:23 pm

    The code should work as is, however the Razor Parser is fighting the javascript intellisense, so you might want to move all your C# code logic out of the script tags since it doesnt need to be inside, like the following:

    @{  
            string isLoggedInDb;
    
            if(Session["isLoggedInDb"] != null)
            {
                if(Session["isLoggedInDb"].ToString() == "1") 
                {
                    isLoggedInDb = "1";
                }
                else
                {
                    isLoggedInDb = "0";
                }
            }
        }
    
     @*....etc*@
    
    <script type="text/javascript">
    
        var dblogin=@(isLoggedInDb);
    
    
    ..etc..
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The below table code in razor in a MVC View, generates a standard table
i have the following code in an asp.net mvc view. <% = Html.DropDownList(Filter, new
I've got the following ASP.NET 4 MVC 3 code in a view: @Html.TextBoxFor(model =>
I have an MVC app with a Partial View (below). When I add Html.EnableClientValidation(),
Given the code block below (source: http://www.asp.net/learn/mvc/tutorial-31-cs.aspx )... I receive this error: Using the
I've a following asp.net mvc razor view code which doesn't seem to be working:
In a MVC view, I have a form as below. when user click on
I have a Edit View generated by VS 2010 (code below). I don't want
I have two classes (MVC view model) which inherits from one abstract base class.
In my MVC view (using VS 2012 RC), I'm attempting to use jQuery to

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.