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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:03:20+00:00 2026-06-09T19:03:20+00:00

Hello guys I have this weird problem with Razor Syntax. I have written the

  • 0

Hello guys I have this weird problem with Razor Syntax.

I have written the same code nuggets in Razor syntax ,having only difference in Inline expression and Multi-statement block.

About.cshtml

   <!-- Single statement blocks -->
   <p>
       Put content here.
       @Html.SubmitButton("You are in About")
   </p>

Rendered Output:
enter image description here

Index.cshtml

<!-- Inline expressions BUT DOESNT WORKS-->
@{ Html.SubmitButton("okay in Index");}

<!-- Multi-statement block BUT DOESNT WORKS-->

@{ 
   Html.SubmitButton("You are in Index");
   Html.CheckBox("A Check Box");
 }

Rendered Output:
enter image description here

P.S: Ignore the input button text in the snapshot.

  • 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-09T19:03:22+00:00Added an answer on June 9, 2026 at 7:03 pm

    The htmlhelpers only return values.

    Even inside code blocks, you still need the @ to tell Razor what to do with those values (print them to the HTML buffer).

    So never-mind with the code block in this case, it would be redundant, as there’s no other code in there but the html-helpers.

    But even if there were other code to be placed within the block, you’d still need to preface the helpers with @:

    @{
        var myVar = "something";
        // and so on ...
    
        @Html.SubmitButton("You are in Index");
        @Html.CheckBox("A Check Box");
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys I have this code in main.php config file: 'components' => array( '[.........]',
Hello guys i have a problem streaming PDF files with php, i'm using this
I have this code: $abc = ' Hello Guys , Goodmorning'; I want to
Hello guys I'm stuck with this weird problem , asp:HyperLink control is not being
Hello Guys! I started learning python GUI development. Let's say I have this script:
Hello guys, I have a general design problem with iPhone application. I want to
Hello guys I have a map like this http://sinanisler.com/demo/map/ and as you can see
Hello Guys! Let's say I have some page which I got with this script:
Hey guys, I have a problem (again). This time I am trying to use
hello guys i have this function for focus : fav[jj].setOnFocusChangeListener(new View.OnFocusChangeListener() { public int

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.