locked
php echo command equivalence of web pages in asp.net RRS feed

  • Question

  • User1109742952 posted

    Hello!

    which is the equivalent of the PHP echo command in ASP.NET WEB PAGES?

    Attentive to your suggestions,
    Thank you,
    regards

    Monday, June 17, 2013 12:30 PM

Answers

  • User281315223 posted

    The echo command within PHP typically handles writing directly to the Response within an application or a web site. If you needed to actually handle this through code-behind, you could use something like the Response.Write() method

    //Explicit Write
    Response.Write("Write what you need here");
    
    //Using a variable
    var yourValue = 1;
    Response.Write(yourValue);

    If you just need to use it within a .cshtml page or within a View, you could simply wrap the value that you want to display within code-blocks (or if you are using the Razor View engine, prefix it with an '@') : 

    //Using the Traditional View Engine
    <% Response.Write("Example"); %>
    
    //Using Razor
    @{ Response.Write("Example"); }
    
    //Directly Writing
    <%= "Example" %>
    
    //Directly Writing using Razor
    @("Example")




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 17, 2013 12:40 PM
  • User143067745 posted

    There are many ways  to show dynamic content

    1.  Respons.Write("Content To Show").
    2. Take a Label In wep page:  you can set it's text property from code behind like: Label1.Text="Content to Show"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 17, 2013 12:42 PM

All replies

  • User281315223 posted

    The echo command within PHP typically handles writing directly to the Response within an application or a web site. If you needed to actually handle this through code-behind, you could use something like the Response.Write() method

    //Explicit Write
    Response.Write("Write what you need here");
    
    //Using a variable
    var yourValue = 1;
    Response.Write(yourValue);

    If you just need to use it within a .cshtml page or within a View, you could simply wrap the value that you want to display within code-blocks (or if you are using the Razor View engine, prefix it with an '@') : 

    //Using the Traditional View Engine
    <% Response.Write("Example"); %>
    
    //Using Razor
    @{ Response.Write("Example"); }
    
    //Directly Writing
    <%= "Example" %>
    
    //Directly Writing using Razor
    @("Example")




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 17, 2013 12:40 PM
  • User143067745 posted

    There are many ways  to show dynamic content

    1.  Respons.Write("Content To Show").
    2. Take a Label In wep page:  you can set it's text property from code behind like: Label1.Text="Content to Show"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 17, 2013 12:42 PM
  • User-821857111 posted

    You use the @ sign to render variables to the browser in Web Pages. See here for more help: http://www.mikesdotnetting.com/Article/153/Inline-Razor-Syntax-Overview

    Monday, June 17, 2013 1:48 PM