abc abc - 3 months ago 8
ASP.NET (C#) Question

how to make the messages to be displayed with some colour

By using below code i am able to download the error messages into excel sheet now what i need to i want to make those error messages to be displayed in some colour how can i do this

string msg1 = (string)Session["Message"];
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=Details.ods");
Response.ContentType = "vnd.oasis.opendocument.text";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
//... Code to write messages ...
StringBuilder objSb = new StringBuilder();
objSb.Append("Messages");
objSb.Append("");
string szText = objSb.ToString();
foreach (var szMessage in msg1)
{
szText = szText + szMessage + "";
}
Response.Write(szText.ToString());
//...
Response.End();

Answer

Please change this line of code:

szText = szText + szMessage + "\r<br>";

To this:

szText += szMessage;
Comments