Results 1 to 5 of 5

Thread: [RESOLVED] HTML Inside ASP.NET COntent Page

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    127

    Resolved [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

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    127

    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

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    127

    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

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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
  •  



Click Here to Expand Forum to Full Width