Click here to Skip to main content
15,903,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();

        img.ImageUrl = "~/images/sample_seller.gif";

        dt = ee.GetContactDetails(CustId);

        StringBuilder sb = new StringBuilder();      

        if (dt.Rows.Count > 0)

        {    

            sb.AppendLine("<html><body><center><table width="100%" cellspacing="0" border="1" hold=" /><br mode="><tr>");

            sb.AppendLine("<td colspan="4" width="100%" align="center" style="background-color: #FFAA2B;">");

            sb.AppendLine(img.ToString());

            sb.AppendLine("</td>");

            sb.AppendLine("</tr>");

            sb.AppendLine("</table></center></body></html>"); 

      }

[Edit]Code block added[/Edit]
Posted
Updated 17-Dec-12 22:58pm
v2

1 solution

Rather than creating the image dynamically in the code....
Seeing as your creating the html for a table and then adding the image to that...

Why not change your code line from
C#
sb.AppendLine(img.ToString());


to the below instead?
C#
sb.AppendLine("<img src='images/sample_seller.gif' />");



Note:
I had added more but i deleted it because the forum processing is messing up the sample code where when i use double and single quotes in a <pre> block it gets screwed up.
 
Share this answer
 
v2
Comments
Zaf Khan 18-Dec-12 5:18am    
Oh the second time its decided to do it properly hahaha as my last code block is correct as intended AND includes both double and single quotes.

The bit i deleted basically said to replace the double quotes inside your append staements with single quotes, but when my sample got screwed up i thought....

Oh wait maybe the guy entered it right (as i did too!) but it got screwed up and single quotes got replaced with double quotes!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900