usercontrol with include file

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default usercontrol with include file

    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 Guest

  2. Similar Questions and Discussions

    1. Strange Include problems: Repeat regions will Not workwith include file
      I have a strange problem. I have an Index.asp page and on that page I have a poll that is displays. This poll is located in a sub folder, so to call...
    2. Event not firing in usercontrol inside usercontrol
      I'm stumped on this problem. I've created a user control that dynamically creates 5 linkbuttons in the CreateChildControls method. Each of these...
    3. proper way to include constants; as module or include file?
      I am developing a new perl module that uses constants with regular expressions. What is the proper way to offer this file? For example, my perl...
    4. Can you share a code behind file with a page and usercontrol?
      Tying not to spaghetti code which seems to be easy to do in .net, im trying to do my main .net html in index.aspx, use repeated .net html in an...
    5. Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack
      a uscontrol test.ascx have a dropdownlist web control the dropdownlist's AutoPostBack property is set "true" but when i use...
  3. #2

    Default Re: usercontrol with include file

    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
    [url]http://brennan.offwhite.net/blog/[/url]

    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 Guest

  4. #3

    Default Re: usercontrol with include file

    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.

    [url]http://brennan.offwhite.net/downloads/IncludeWebsite.zip[/url]

    Brennan Stehling
    [url]http://brennan.offwhite.net/blog/[/url]

    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 Guest

  5. #4

    Default Re: usercontrol with include file

    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" <offwhite@gmail.com> wrote in message
    news:1161890061.433864.276980@e3g2000cwe.googlegro ups.com...
    > 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.
    >
    > [url]http://brennan.offwhite.net/downloads/IncludeWebsite.zip[/url]
    >
    > Brennan Stehling
    > [url]http://brennan.offwhite.net/blog/[/url]
    >
    > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139