Where is this ASP.NET feature documented? <%= string format, params object[] args %> Where is this ASP.NET feature documented? <%= string format, params object[] args %> asp.net asp.net

Where is this ASP.NET feature documented? <%= string format, params object[] args %>


As far as I know the ASP.NET parser translates <%= %> into a call to HttpResponse.Write(string).

Maybe the <%= "{0} is {1}", "Foo", 42 %> is translated to Response.Output.Write(string format, params object[] arg), Output being of type TextWriter, which would be the explanation according to http://www.hanselman.com/blog/ASPNETResponseWriteAndResponseOutputWriteKnowTheDifference.aspx


This is an <%= %> embedded code block and exists to maintain compatibility with Classic ASP.

As you saw <%= "{0} is {1}", "Foo", 42 %> is equivalent to:

string s = string.Format("{0} is {1}", "Foo", 42);Response.Write(s);

That behavior is documented here:

Writes a formatted string that contains the text representation of an object array to the output stream, along with any pending tab spacing. This method uses the same semantics as the String.Format method. (Overrides TextWriter.Write(String, Object[]).)

Here is where it's documented that the Code Render Block calls the Write method.

Finally, the syntax for embedded code blocks has been updated for .NET 4 as described here.