usercontrol with include file

Discussion in 'ASP .Net Building Controls' started by Shailesh Patel, Oct 26, 2006.

  1. Hi,

    I put include file in usercontrol and use this UC in another aspx page.
    However, aspx file writes <!-- #include virtual="/fres/fues.htm" --> in aspx
    file but did not display content of include file.
    I would like to know how to do this?

    Thank you.

    Shailesh
     
    Shailesh Patel, Oct 26, 2006
    #1
    1. Advertising

  2. Shailesh,

    I have not see that include syntax in ASP.NET as it was in classic ASP.
    If I wanted to include static content within a ASPX page, I would do
    this...

    1) Create a User Control called Include.ascx
    2) Add a Literal control to that User Control
    3) Add a Property to the code-behind called Virtual or File as a String
    4) For the Load handler, I would read the contents of that file and set
    the Text property of the Literal control

    That would bring the contents of that control into your page. In the
    ASPX page, you would reference the User Control like...

    <uc1:Include ID="Include1" runat="server" Virtual="~/file.html" />

    And to speed things up a little, I would use System.Web.Caching to hold
    the contents of the file with a dependency on the referenced file.

    Once you have this User Control you can use it for any website you
    build.

    Brennan Stehling
    http://brennan.offwhite.net/blog/

    Shailesh Patel wrote:
    > Hi,
    >
    > I put include file in usercontrol and use this UC in another aspx page.
    > However, aspx file writes <!-- #include virtual="/fres/fues.htm" --> in aspx
    > file but did not display content of include file.
    > I would like to know how to do this?
    >
    > Thank you.
    >
    > Shailesh
     
    Brennan Stehling, Oct 26, 2006
    #2
    1. Advertising

  3. Shailesh,

    I thought this was interesting so I created a sample ASP.NET 2.0
    website with the User Control I described here.

    You can download it here.

    http://brennan.offwhite.net/downloads/IncludeWebsite.zip

    Brennan Stehling
    http://brennan.offwhite.net/blog/

    Shailesh Patel wrote:
    > Hi,
    >
    > I put include file in usercontrol and use this UC in another aspx page.
    > However, aspx file writes <!-- #include virtual="/fres/fues.htm" --> in aspx
    > file but did not display content of include file.
    > I would like to know how to do this?
    >
    > Thank you.
    >
    > Shailesh
     
    Brennan Stehling, Oct 26, 2006
    #3
  4. Hi Brennan,
    I tried to download file and gives me
    "End-of-central-directory signature not found. Either this file is not a Zip
    file, or it constitutes one disk of a multi-part Zip file."
    while unzipping.
    But I got your point and try it.
    Thank you.

    "Brennan Stehling" <> wrote in message
    news:...
    > Shailesh,
    >
    > I thought this was interesting so I created a sample ASP.NET 2.0
    > website with the User Control I described here.
    >
    > You can download it here.
    >
    > http://brennan.offwhite.net/downloads/IncludeWebsite.zip
    >
    > Brennan Stehling
    > http://brennan.offwhite.net/blog/
    >
    > Shailesh Patel wrote:
    >> Hi,
    >>
    >> I put include file in usercontrol and use this UC in another aspx page.
    >> However, aspx file writes <!-- #include virtual="/fres/fues.htm" --> in
    >> aspx
    >> file but did not display content of include file.
    >> I would like to know how to do this?
    >>
    >> Thank you.
    >>
    >> Shailesh

    >
     
    Shailesh Patel, Oct 27, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Bazarov

    #include "file" -vs- #include <file>

    Victor Bazarov, Mar 5, 2005, in forum: C++
    Replies:
    4
    Views:
    565
    Exits Funnel
    Mar 6, 2005
  2. PTM
    Replies:
    1
    Views:
    354
    Andy Dingley
    Nov 12, 2007
  3. naveeddil
    Replies:
    0
    Views:
    620
    naveeddil
    Jan 4, 2008
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    1,001
    Andreas Bogenberger
    Feb 22, 2008
  5. Eric
    Replies:
    10
    Views:
    499
Loading...

Share This Page