usercontrol with include file

S

Shailesh Patel

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
 
B

Brennan Stehling

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/
 
S

Shailesh Patel

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top