Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / October 2006

Tip: Looking for answers? Try searching our database.

usercontrol with include file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shailesh Patel - 26 Oct 2006 18:14 GMT
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 - 26 Oct 2006 19:27 GMT
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/

> Hi,
>
[quoted text clipped - 6 lines]
>
> Shailesh
Brennan Stehling - 26 Oct 2006 20:14 GMT
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/

> Hi,
>
[quoted text clipped - 6 lines]
>
> Shailesh
Shailesh Patel - 27 Oct 2006 14:41 GMT
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.

> Shailesh,
>
[quoted text clipped - 19 lines]
>>
>> Shailesh

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.