HighTechTalks DotNet Forums  

usercontrol with include file

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss usercontrol with include file in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Shailesh Patel
 
Posts: n/a

Default usercontrol with include file - 10-26-2006 , 01:14 PM






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



Reply With Quote
  #2  
Old   
Brennan Stehling
 
Posts: n/a

Default Re: usercontrol with include file - 10-26-2006 , 02:27 PM






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:
Quote:
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


Reply With Quote
  #3  
Old   
Brennan Stehling
 
Posts: n/a

Default Re: usercontrol with include file - 10-26-2006 , 03:14 PM



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/download...udeWebsite.zip

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

Shailesh Patel wrote:
Quote:
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


Reply With Quote
  #4  
Old   
Shailesh Patel
 
Posts: n/a

Default Re: usercontrol with include file - 10-27-2006 , 09:41 AM



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 (AT) gmail (DOT) com> wrote

Quote:
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/download...udeWebsite.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




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.