?
Solved

import html file

Posted on 2006-03-24
8
Medium Priority
?
274 Views
Last Modified: 2008-03-04
Good Morning Experts,

Using the code behind, how would I import an html file into a aspx page on_load?

Thanks!
   - Marc
0
Comment
Question by:MarcGraff
8 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 16282029
I'm not sure why you are interested in doing this. You can always use an include statement in the code in front.

<!-- #include virtual="/somefile.html" -->

But if you need to include it in the code behind, you can use a streamreader.
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 16282095
Good Afternoon strickdd,

We have different menus depending on the user. the menus are done in html because they are used in multiple languages. The reason I need this in the codebehind is so I can pull the correct menu for the correct user.

   - Marc

0
 
LVL 5

Accepted Solution

by:
Argblat earned 1600 total points
ID: 16282365
Instead of storing the different menus as html, why don't you store them as txt files. Strip out all the unecessary code (like head or body tags) if you haven't already...  

Then, in your code behind, figure out who the user is, figure out which menu to display for that user, and then read in the appropriate text file, and assign it to an inline variable or an asp label (if you can get away without having any issues becuse an asp label will add span tags around the text) following the advice of the following article for reading in txt files:

http://aspnet.4guysfromrolla.com/articles/051802-1.aspx


To specify one thing, by inline variable I mean the following
In your html design you add the following

<%=Menu_HTML%>

In your code behind you register this variable as a protected string
In c# it looks like this: protected string Menu_HTML;
It goes right after the public class definition (where all the server controls are defined as protected)

Then in your code you can assign a value to the variable by simply doing something like

Menu_HTML = "This text will show up on your page whever you added the variable declaration";

Hope that helps....
-Mike
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:strickdd
ID: 16283435
I wouldn't recommend using a Literal control instead of the <%=Menu_HTML%>. It is the more ".Net way" of doing things. All you have to do is set the literalObj.Text = HTMLText.

To get the HTML text just use a streamreader on whatever file you have it saved as.
0
 
LVL 28

Expert Comment

by:strickdd
ID: 16283440
Another option, which is probably even better would be to use a masterpage with the different menus in it. Have the menues be in panels and then you can set the visibility to true or false depending on the user type.
0
 
LVL 12

Expert Comment

by:bsdotnet
ID: 16286844
0
 
LVL 28

Assisted Solution

by:strickdd
strickdd earned 400 total points
ID: 16289146
A label control uses the property innerhtml that needs to be set and can be frustrating if you just select the .text property. With a literal you keep consistency by only setting .text properties.
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 16294321
Thanks so much! I have it up are running perfectly!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question