By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

ASP.Net Page that has a control to display HTML

P: n/a
I need a control on a Web Page that can accept an HTML Document and will display it.

Any help would be appreciated.

Thanks,
Dave
Here is what I was trying...
protected System.Web.UI.WebControls.Panel htmlPanel;
protected System.Web.UI.WebControls.Image htmlImage;
htmlString = @"ImageFeed.aspx?docId=" + docID;

htmlPanel.BackImageUrl = htmlString;

htmlImage.ImageUrl = htmlString;
htmlImage.Visible = true;

public class ImageFeed : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
string htmlData = @"<html><body><h3>Hello World</h3></body></html>";
Response.Write(htmlData);
}
}
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi, David Elliott,

How about an iframe? In the class you can declare it as
System.Web.UI.HtmlControls.HtmlGenericControl, just don't forget the
runat="server" attribute in the .aspx. You can set the attributes (src,
width, height, border, etc) from the property Attributes, i.e.
iframe1.Attributes["src"] = "somepage.aspx";

Greetings
Martin
"David Elliott" <Da**********@BellSouth.net.nospam> wrote in message
news:si********************************@4ax.com...
I need a control on a Web Page that can accept an HTML Document and will display it.
Any help would be appreciated.

Thanks,
Dave
Here is what I was trying...
protected System.Web.UI.WebControls.Panel htmlPanel;
protected System.Web.UI.WebControls.Image htmlImage;
htmlString = @"ImageFeed.aspx?docId=" + docID;

htmlPanel.BackImageUrl = htmlString;

htmlImage.ImageUrl = htmlString;
htmlImage.Visible = true;

public class ImageFeed : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
string htmlData = @"<html><body><h3>Hello World</h3></body></html>";
Response.Write(htmlData);
}
}

Nov 18 '05 #2

P: n/a
Use the WebControls.Literal control

Set the Literal.Text property to store the HTML content

HTH
Tim Stal

----- David Elliott wrote: ----

I need a control on a Web Page that can accept an HTML Document and will display it

Any help would be appreciated

Thanks
Dav
Here is what I was trying..
protected System.Web.UI.WebControls.Panel htmlPanel
protected System.Web.UI.WebControls.Image htmlImage
htmlString = @"ImageFeed.aspx?docId=" + docID

htmlPanel.BackImageUrl = htmlString

htmlImage.ImageUrl = htmlString
htmlImage.Visible = true

public class ImageFeed : System.Web.UI.Pag

private void Page_Load(object sender, System.EventArgs e

string htmlData = @"<html><body><h3>Hello World</h3></body></html>"
Response.Write(htmlData)

Nov 18 '05 #3

P: n/a

I added <iframe id=extText runat=server></iframe> to my ASPX page and defined
protected System.Web.UI.HtmlControls.HtmlGenericControl extText;

htmlString = @"ImageFeed.aspx?docId=" + docID;
extText.Attributes["src"] = htmlString;

If I have ImageFeed defined to return:
dataString = @"<html><body><h1>hello world 12</h1></body></html>";
Response.Write(dataString);
Response.Flush();
Response.Close();

Everything works fine.

=======================

If I cache a file
FileStream fs = new FileStream(filename, FileMode.Open);
byte[] data = new byte [fs.Length];
fs.Read(data, 0, (int)fs.Length);
fs.Close();

and have ImageFeed defined to return
data = (byte[])document;
string dataString = Encoding.UTF8.GetString(data);

Response.Write(dataString);
Response.Flush();
Response.Close();

This doesn't work. Using the debugger, I verified that dataString has the correct information (i.e. the HTML)

If I view the source it returns some generated text from who knows where. Isn't anything like what I am trying
to load. It looks like this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>ImageFeed</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="ImageFeed.aspx?r0=1077912660" id="Form1">
<input type="hidden" name="__VIEWSTATE" value="dDwtMTI3OTMzNDM4NDs7Ppf+ZVIuJLGxTqy+PZFowk7 vf36y" />

</form>
</body>
</HTML>
Any help would be appreciated.

Thanks,
Dave

On Fri, 27 Feb 2004 19:53:18 +0100, "Martin Dechev" <de******@hotmail.com> wrote:
Hi, David Elliott,

How about an iframe? In the class you can declare it as
System.Web.UI.HtmlControls.HtmlGenericControl, just don't forget the
runat="server" attribute in the .aspx. You can set the attributes (src,
width, height, border, etc) from the property Attributes, i.e.
iframe1.Attributes["src"] = "somepage.aspx";

Greetings
Martin
"David Elliott" <Da**********@BellSouth.net.nospam> wrote in message
news:si********************************@4ax.com.. .
I need a control on a Web Page that can accept an HTML Document and will

display it.

Any help would be appreciated.

Thanks,
Dave
Here is what I was trying...
protected System.Web.UI.WebControls.Panel htmlPanel;
protected System.Web.UI.WebControls.Image htmlImage;
htmlString = @"ImageFeed.aspx?docId=" + docID;

htmlPanel.BackImageUrl = htmlString;

htmlImage.ImageUrl = htmlString;
htmlImage.Visible = true;

public class ImageFeed : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
string htmlData = @"<html><body><h3>Hello World</h3></body></html>";
Response.Write(htmlData);
}
}


Nov 18 '05 #4

P: n/a
Hi, David Elliott,

Are you sure that you are not viewing a cached version of the page? Delete
your temp. files in the IE. If you are running Windows Server (IIS 6.0) you
might need to restart the w3svc service because there is some bizzare
caching which is not documented but many people are experiencing it.

Also, call Response.End() instead of Response.Close()

Greetings
Martin
"David Elliott" <Da**********@BellSouth.net.nospam> wrote in message
news:pf********************************@4ax.com...

I added <iframe id=extText runat=server></iframe> to my ASPX page and defined protected System.Web.UI.HtmlControls.HtmlGenericControl extText;

htmlString = @"ImageFeed.aspx?docId=" + docID;
extText.Attributes["src"] = htmlString;

If I have ImageFeed defined to return:
dataString = @"<html><body><h1>hello world 12</h1></body></html>";
Response.Write(dataString);
Response.Flush();
Response.Close();

Everything works fine.

=======================

If I cache a file
FileStream fs = new FileStream(filename, FileMode.Open);
byte[] data = new byte [fs.Length];
fs.Read(data, 0, (int)fs.Length);
fs.Close();

and have ImageFeed defined to return
data = (byte[])document;
string dataString = Encoding.UTF8.GetString(data);

Response.Write(dataString);
Response.Flush();
Response.Close();

This doesn't work. Using the debugger, I verified that dataString has the correct information (i.e. the HTML)
If I view the source it returns some generated text from who knows where. Isn't anything like what I am trying to load. It looks like this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>ImageFeed</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="ImageFeed.aspx?r0=1077912660" id="Form1"> <input type="hidden" name="__VIEWSTATE" value="dDwtMTI3OTMzNDM4NDs7Ppf+ZVIuJLGxTqy+PZFowk7 vf36y" />
</form>
</body>
</HTML>
Any help would be appreciated.

Thanks,
Dave

On Fri, 27 Feb 2004 19:53:18 +0100, "Martin Dechev" <de******@hotmail.com> wrote:
Hi, David Elliott,

How about an iframe? In the class you can declare it as
System.Web.UI.HtmlControls.HtmlGenericControl, just don't forget the
runat="server" attribute in the .aspx. You can set the attributes (src,
width, height, border, etc) from the property Attributes, i.e.
iframe1.Attributes["src"] = "somepage.aspx";

Greetings
Martin
"David Elliott" <Da**********@BellSouth.net.nospam> wrote in message
news:si********************************@4ax.com.. .
I need a control on a Web Page that can accept an HTML Document and
willdisplay it.

Any help would be appreciated.

Thanks,
Dave
Here is what I was trying...
protected System.Web.UI.WebControls.Panel htmlPanel;
protected System.Web.UI.WebControls.Image htmlImage;
htmlString = @"ImageFeed.aspx?docId=" + docID;

htmlPanel.BackImageUrl = htmlString;

htmlImage.ImageUrl = htmlString;
htmlImage.Visible = true;

public class ImageFeed : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
string htmlData = @"<html><body><h3>Hello World</h3></body></html>";
Response.Write(htmlData);
}
}

Nov 18 '05 #5

P: n/a
I changed from Close() to End() as suggested and it throws an exception:
ex.Message "Thread was being aborted.". I was using a simple hard coded
string " <html><body><h1>This is some text</h1></body></html>"

The failure to display the HTML, I believe it has something to do with the data
contained inside of the HTML file. If I create a file using the string above, the
output is displayed correctly. Upon viewing the source, it is identical to the
file on disk. No additional headers or information.

The data file I had been using for testing purposes was the Yahoo.com main page.
I just saved it to disk and then read it into a byte[] (see previous message below)
and then do the write. Using this yahoo.htm file instead of the simple html file, I get
nothing displayed. When I view the source code, the following is displayed which
doesn't look like the Yahoo.com file on disk..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>ImageFeed</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="ImageFeed.aspx?r0=1077912660"
id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtMTI3OTMzNDM4NDs7Ppf+ZVIuJLGxTqy+PZFowk7 vf36y" />

</form>
</body>
</HTML>

Cheers,
Dave

On Fri, 27 Feb 2004 21:27:09 +0100, "Martin Dechev" <de******@hotmail.com> wrote:
Hi, David Elliott,

Are you sure that you are not viewing a cached version of the page? Delete
your temp. files in the IE. If you are running Windows Server (IIS 6.0) you
might need to restart the w3svc service because there is some bizzare
caching which is not documented but many people are experiencing it.

Also, call Response.End() instead of Response.Close()

Greetings
Martin
"David Elliott" <Da**********@BellSouth.net.nospam> wrote in message
news:pf********************************@4ax.com.. .

I added <iframe id=extText runat=server></iframe> to my ASPX page and

defined
protected System.Web.UI.HtmlControls.HtmlGenericControl extText;

htmlString = @"ImageFeed.aspx?docId=" + docID;
extText.Attributes["src"] = htmlString;

If I have ImageFeed defined to return:
dataString = @"<html><body><h1>hello world 12</h1></body></html>";
Response.Write(dataString);
Response.Flush();
Response.Close();

Everything works fine.

=======================

If I cache a file
FileStream fs = new FileStream(filename, FileMode.Open);
byte[] data = new byte [fs.Length];
fs.Read(data, 0, (int)fs.Length);
fs.Close();

and have ImageFeed defined to return
data = (byte[])document;
string dataString = Encoding.UTF8.GetString(data);

Response.Write(dataString);
Response.Flush();
Response.Close();

This doesn't work. Using the debugger, I verified that dataString has the

correct information (i.e. the HTML)

If I view the source it returns some generated text from who knows where.

Isn't anything like what I am trying
to load. It looks like this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>ImageFeed</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"

content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="ImageFeed.aspx?r0=1077912660"

id="Form1">
<input type="hidden" name="__VIEWSTATE"

value="dDwtMTI3OTMzNDM4NDs7Ppf+ZVIuJLGxTqy+PZFowk 7vf36y" />

</form>
</body>
</HTML>
Any help would be appreciated.

Thanks,
Dave

On Fri, 27 Feb 2004 19:53:18 +0100, "Martin Dechev" <de******@hotmail.com>

wrote:
>Hi, David Elliott,
>
>How about an iframe? In the class you can declare it as
>System.Web.UI.HtmlControls.HtmlGenericControl, just don't forget the
>runat="server" attribute in the .aspx. You can set the attributes (src,
>width, height, border, etc) from the property Attributes, i.e.
>iframe1.Attributes["src"] = "somepage.aspx";
>
>Greetings
>Martin
>"David Elliott" <Da**********@BellSouth.net.nospam> wrote in message
>news:si********************************@4ax.com.. .
>> I need a control on a Web Page that can accept an HTML Document andwill >display it.
>>
>> Any help would be appreciated.
>>
>> Thanks,
>> Dave
>>
>>
>> Here is what I was trying...
>>
>>
>> protected System.Web.UI.WebControls.Panel htmlPanel;
>> protected System.Web.UI.WebControls.Image htmlImage;
>>
>>
>> htmlString = @"ImageFeed.aspx?docId=" + docID;
>>
>> htmlPanel.BackImageUrl = htmlString;
>>
>> htmlImage.ImageUrl = htmlString;
>> htmlImage.Visible = true;
>>
>>
>>
>> public class ImageFeed : System.Web.UI.Page
>> {
>> private void Page_Load(object sender, System.EventArgs e)
>> {
>> string htmlData = @"<html><body><h3>Hello World</h3></body></html>";
>> Response.Write(htmlData);
>> }
>> }
>


Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.