What Is the ASP.NET Equivalent to PHP's Echo

What is the ASP.Net equivalent to PHP's Echo?

Use Response.Write(string).

There are a couple of shortcuts to Response.Write if you are trying to output on the page:

<%="sergio|tapia|1999|10am"%>

Or

<%:"sergio|tapia|1999|10am"%> (.NET 4.0)

See here for the different options.

Is there an equivalent of echo in asp.net c#

The one-for-one equivalent would be Response.Write:

Response.Write("some text");

That said, ASP .NET and PHP are very different frameworks. With ASP .NET (including the MVC framework) there is rarely a need to write directly to the response stream in this manner.

One such case would be if you wanted to return a very lightweight response. You could do something like this:

Response.ContentType = "text/xml";
Response.Write("<root someAttribute = 'value!' />");

Any method other than using Response directly can (and probably will) alter the output. So in short - if you want to just dump raw data into the HttpResponse, you'll want to use Response.Write().

.net Razor alternative to PHP echo

Use this:

@String.Format("[{0},{1}]", i, Math.Sin(i))

And for comma you can use String.Join() if you create array (String.Join Method )

Does PHP have an equivalent of ASP.NET Placeholder?

You can use some templating engine (Smarty, Twig, ...) to keep php code and html separated. But if you want to use inline php, just use

<?php
$block_visible = false;
?>

rest of your code here

<?php
if ( $block_visible ) {
?>
.... your code here ...
<?php
}
?>

or this one (to avoid curly braces)

<?php if ($block_visible) : ?>
Your html here
<?php endif; ?>

What's the equivalent of this PHP code for ASP.NET, is there any?

The answer seems to be that it's not possible to convert the concept easily. As highlighted by the comments.

Equivalent of php echo in C# for inline text

Try using the direct syntax of razor
@("")

What's The Equilavent of PHP code: header() in Asp.Net?

HttpContext.Current.Response.Headers.Add

HttpContext.Current.Response.AddHeader

asp.net equivalent of simple php code

Have a read of http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/ and http://encosia.com/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/

The correct webservices should output JSON objects.

If you want a JSON serialiser then have a look at: http://json.codeplex.com/

Using @safarov's code, you should be able to call the serialise method to return it as a JSON string:

Newtonsoft.Json.JsonConvert.SerializeObject(someObject)


Related Topics



Leave a reply



Submit