Friday, 21 September 2012

Differentiate Response. write & Response.output.write?

Response.Write and Response.Output.Write are both used to write messages on the screen. But Using Reponse.Output.Write() you can display formattable output while Response.Write() can only display single character line.

  • Formatted output will be displayed.
  • It gives String.Format-style formatted output.
  • It writes the HTTP Output Stream.
  • As per specified options it formats the string and then write to web page.

Example :
Response.Output.Write("{0} is {1:d}", "Current Date Time is: ",DateTime.Now);

  • unformatted output will be displayed.
  • It never gives like that.
  • It writes the text stream
  • It just output a string to web page.

Example :
Response.Write("Current Date Time is "+DateTime.Now.ToString());

No comments:

Post a Comment