473,466 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HTML in C# just prints it as text in HTML file and not html code

Sl1ver
196 New Member
i have this in my C#

Expand|Select|Wrap|Line Numbers
  1.  
  2. sData +=    "<div id=\"div1\"> " +
  3.             "<img src=\"http://www.system.pushplay.co.za/images/covers/big/big_<%=vcimagename %>\" width=\"80\" height=\"100\" /> " +
  4.             "</div>" +
  5.             "<div id=\"div2\"> " +
  6.             "<table> " +
  7.             "<tr>" +
  8.             "<td> " +
  9.             "<%=vctitlename.Replace(\"@\",\"<br/>\") %>(<%=vccertificate %>)&nbsp;<%=intyear %>  " +
  10.             "</td> " +
  11.             "</tr> " +
  12.             "<tr> " +
  13.             "<td> " +
  14.             "Starring: <%=titleactorlist %> " +
  15.             "</td> " +
  16.             "</tr> " +
  17.             "<tr> " +
  18.             "<td> " +
  19.             "<%=vcshortdesc%><br /> " +
  20.             "</td> " +
  21.             "</tr> " +
  22.             "</table> "+
  23.             "</div> " ;
  24.  
  25.             encodedHtml = Server.HtmlEncode(sData);
  26.  
The problem is it prints it as text in the html file instead of actually making it html so that i see the page properly.

This is what i see as a "string" once the html page is loaded

<div id="div1"> <img src="http://www.system.pushplay.co.za/images/covers/big/big_<%=vcimagename %>" width="80" height="100" /> </div><div id="div2"> <table> <tr><td> <%=vctitlename.Replace("@","<br/>") %>(<%=vccertificate %>)&nbsp;<%=intyear %> </td> </tr> <tr> <td> Starring: <%=titleactorlist %> </td> </tr> <tr> <td> <%=vcshortdesc%><br /> </td> </tr> </table> </div>
Oct 4 '11 #1
1 1690
Frinavale
9,735 Recognized Expert Moderator Expert
ASP.NET automatically does this for you because it wants to make sure that HTML isn't inserted into the page by accident. You need to turn encoding off for that control.

Why oh why would you take this approach though??
It would make a lot more sense to use a proper Repeater or Table or GridView or some other control...

-Frinny
Oct 4 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Himanshu Garg | last post by:
Hello, I am using HTML::Parser to extract text from html pages from http://bbc.co.uk/urdu/ However the encoding of the input text seems to change to some unknown encoding in the output. The...
10
by: J. Alan Rueckgauer | last post by:
Hello. I'm looking for a simple way to do the following: We have a database that serves-up content to a website. Some of those items are events, some are news articles. They're stored in the...
5
by: ashton | last post by:
Hello, I have a file (mytest.fle) it is just a text file with a different extension. I would like to be able to open this file through my C++ application and read it in as a string. For...
2
by: Robin | last post by:
Hello I need to read the rendered text of a html file. Does anybody know how to do that? Thanks
6
by: Ksenia Marasanova | last post by:
Hi, I am looking for a library that will give me very simple text representation of HTML. For example <div><h1>Title</h1><p>This is a <br />test</p></div> will be transformed to: Title
5
Markus
by: Markus | last post by:
I'll leave out the annoying 'i'm a newbie' speech and get to the point: i'm a newbie at perl ;) First thing i ever wrote in perl and it doesnt work. I'm using xampp as my localhost - with perl...
7
by: jcnone | last post by:
Does anyone know how to populate form fields on a html web page (client side) with data from an Excel file (CSV) or text file. I am currently having to input data to many text fields manually. I...
66
by: happyse27 | last post by:
Hi All, my html code is sno 1) and perl code is sno 2). a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it...
1
by: Ormazd | last post by:
Hello, I was wondering if anyone might be able to help me with a little PERL script? I'm very new and I have been given a task to write a simple Perl script that prints out the file names and...
0
by: dbphydb | last post by:
Hi, I want to search for a particular text on an html page ---> Build Complete Further execution should be only if the build is successful which is denoted by the text 'Build Complete' on the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.