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

Home Posts Topics Members FAQ

display actual HTML in text box

I'm actually trying render usercontrols dynamicaly fraom a name stored
in a db, but am have problems. My debugging attempts involve trying to
write the contents of the .aspx to a label, but this is just giving me
the text and actually rendering the html, I just want the raw code.
void someMethod()
{
string ucstring = "";
blah.GenericData gd = new GenericData(); // my own data class
SqlDataReader dr;
dr = gd.getByString
(@"select Category_Spec
from Categories
where Category_Name = 'End Caps'");

while(dr.Read())
{
ucstring = dr.GetSqlValue(0).ToString();
}

StreamReader sr = new StreamReader
(@"C:\Inetpub\wwwroot\blah\pecs\" + ucstring);

s = sr.ReadToEnd();
Literal1.Text = s; // should render HTML tags as well??
}

Anyone have the answer to this one?
Nov 15 '05 #1
2 4055
On Fri, 20 Feb 2004 13:45:27 GMT, Adie wrote:
I'm actually trying render usercontrols dynamicaly fraom a name stored
in a db, but am have problems. My debugging attempts involve trying to
write the contents of the .aspx to a label, but this is just giving me
the text and actually rendering the html, I just want the raw code.

void someMethod()
{
string ucstring = "";
blah.GenericData gd = new GenericData(); // my own data class
SqlDataReader dr;
dr = gd.getByString
(@"select Category_Spec
from Categories
where Category_Name = 'End Caps'");

while(dr.Read())
{
ucstring = dr.GetSqlValue(0).ToString();
}

StreamReader sr = new StreamReader
(@"C:\Inetpub\wwwroot\blah\pecs\" + ucstring);

s = sr.ReadToEnd();
Literal1.Text = s; // should render HTML tags as well??
}

Anyone have the answer to this one?


One solution would be to have the content displayed in a <textarea>
block (TextBox with multiline set to true in .Net) instead of the
literal. It also looks like you do not close your DataReader (at least
not in the code you posted) which may cause some problems for you as
well.

HTH,
Tim
--
I only know as much about myself as my mind can work out under its
current conditions. And its current conditions are not good.
Nov 15 '05 #2
Adie wrote:

[snip]

Found the solution to displaying dynamic user controls made from any
file:

void someMethod
{
string s = "",ucstring="";
SomeOtherApp.GenericData gd = new GenericData(); //
SqlDataReader sqlDR;

// get the name of the aspx file to load from database
sqlDR = gd.getByString
(@"SELECT Category_Spec
FROM Categories
WHERE Category_Name = 'End Caps'");

while(sqlDR.Read())
{ // aspx filename to string value
ucstring =
sqlDR.GetSqlValue(0).
ToString();
}

// read the HTML contents of the file
StreamReader sr = new StreamReader
(@"C:\Inetpub\wwwroot\MainApp\pecs\" + ucstring);
s = sr.ReadToEnd()

// create control from HTML string;
Control c = ParseControl(s);
PlHdrSpecs.Controls.Add(c);
PnlSpecs.Controls.Add(PlHdrSpecs);
}

To display raw html code with tags use

Label1.Text = Server.HtmlEncode(HTMLstringToDispay);
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Oliver | last post by:
Hello, i'm having trouble with a css type popup. It's not doing what i want in Mozilla 1.6 and in IE6.0 it's not working at all. The html code looks like this: <div class="themenkueche"...
23
by: Mat | last post by:
<div id="container"> <div id="main"> <div id="header"> <p class="Address">123 Fake Street, </p> <p class="City">Crazy City, </p> <p class="Province">Ontario </p> <p class="PostalCode">H0H...
4
by: Nick | last post by:
I would like to have a errorMessage displayed in a webpage. When a function is called the text changes. My code below replaces the html page with the errorMessage instead of embedding it into the...
2
by: ruby_bestcoder | last post by:
Hi Im having problem in firefox with display:none/block. I have essentially 3 li elements. In each element there are a few nested div:s. Clicking on one of the divs, makes another div to...
3
by: Paul | last post by:
I found a great site for CSS tempaltes, http://blog.html.it/layoutgala/ . I downloaded them, and played around with them. Then I tried to use the template in as ASP.Net MasterPage, but everything...
1
by: bigmaddaz | last post by:
Ok im designing an application for working out compount interest. The user starts the page, 3 prompts appear, one asking for money invested, next asking for rate of interest, and last one asking for...
5
by: libsfan01 | last post by:
function switch_display(switchme) { var el = document.getElementById(switchme); el.style.display = (el.style.display == 'none')? '' : 'none'; } im using this function to switch the display on...
7
by: jediknight | last post by:
Does anyone know of any examples of doing LED style text displays? I need to implement a text display which has one line of 20 characters. There was an example on Codeproject but I cannot seem...
17
by: Phil M | last post by:
Hi all. I have am HTML web page where I upload an updated file which is always called document.pdf. Users get there, click on the icon and download the document.pdf. Below the icon/link where...
15
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out,...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.