|
-
Oct 14th, 2007, 03:00 PM
#1
Thread Starter
Lively Member
[RESOLVED] HTML Inside ASP.NET COntent Page
I guess I am not wording the search right, because I am SURE someone has done this...
I want to display the contents of an HTML file inside a contentplaceholder (or on any ASP.NET page for all it really matters)
What I am trying to do is have a page written in HTML displayed on an ASP.NET page to look contiguous - The reason being, I want a couple of pages on the site to be editable easily by the client without having to mess with the core code of the compiled ASP.NET website...
The issue is LINKING to the external file (like #include) - but I can't find the syntax.
Appreciate any help
Scott
-
Oct 14th, 2007, 03:52 PM
#2
Re: HTML Inside ASP.NET COntent Page
That would depend on how and where the external content is stored.
If it's a file local to your application, you would use System.IO.File to read the contents.
If it's a remote file, you could use a HttpWebRequest to retrieve the contents.
In either case, use a Literal control to display the content - simply add the literal to your content placeholder.
-
Oct 14th, 2007, 04:29 PM
#3
Thread Starter
Lively Member
Re: HTML Inside ASP.NET COntent Page
the content will be stored as an .htm file in a subdir of the root
ie. ~\mydir\myhtmfile.htm
I was looking at the literal control - I was able to figure out the text = "mytexthere" method of insertion, but I could not figure out how to call a file
<asp:Literal ID="Literal1" runat="server" Text="my text here"></asp:Literal>
I assume that the call goes between the tags, but I couldn't figure out how - tried all sorts of stuff
Even a labotomy - hehe
I assume you are suggesting I use System.io to read the contents into a string variable in VB or C#/++....
Once I do that (say to MyHTMLString as String ), how/where do I insert it into the literal tag??
(and thanks for the other reply !!)
Scott
-
Oct 14th, 2007, 04:39 PM
#4
Thread Starter
Lively Member
Re: HTML Inside ASP.NET COntent Page
Ah - playing help - haven't read the html file in yet, but
On the ASP.net page
<asp:Literal ID="Literal1" runat="server" ></asp:Literal>
In the VB.NET Page_LOAD
Literal1.text = "Either string or variable here"
So, I guess all I do is read the HTML file into a string and good to go...
DOH.... Always the simple stuff that is hard to figure out, eh??
Cheers
Scott
-
Oct 16th, 2007, 08:36 AM
#5
Re: [RESOLVED] HTML Inside ASP.NET COntent Page
Code:
System.IO.StreamReader myFile = new System.IO.StreamReader("c:\\blaaaah.html");
string myString = myFile.ReadToEnd();
Since it's in your string then, assign to literal.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|