Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 233375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:05:44+00:00 2026-05-11T20:05:44+00:00

I have a page that has a left menu in it. This left menu

  • 0

I have a page that has a left menu in it. This left menu is an HTML file [LeftFrame.htm] and is included in the aspx page using the following code.

<!-- #include file="LeftFrame.htm"-->

Now I need to change the file name to LeftFrameOthers.htm from C# code.

Eg:

if ( arg == 1 )
{
    divMenu.InnerHTML = "<!-- #include file="LeftFrame.htm"-->";
}
else
{
     divMenu.InnerHTML = "<!-- #include file="LeftFrameOthers.htm"-->";
}

But it creates an error and left menu is not loaded. Is there a way to manage this from C# code.

I don’t want to use two divs for this purpose like..

<div id="divOwnLeftFrame" runat="server" style="DISPLAY: block">
           <!-- #include file="LeftFrame.htm"--></div><div id="divOthersLeftFrame" runat="server" style="DISPLAY: block">
          <!-- #include file="LeftProfileFrame.htm"-->
</div>

and change the display property of the divs from C# code.

I am using VS 2003

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:05:44+00:00Added an answer on May 11, 2026 at 8:05 pm

    The use of include files in ASP.NET has generally been superseded by user controls which are much more powerful. Here’s another alternative to using include files:

    ASPX:

    <asp:Literal ID="FrameLiteral" runat="server" />
    

    Code behind:

    private string GetFrameContent(int arg)
    {
        string filename = (arg == 1) ? "LeftFrame.htm" : "LeftFrameOthers.htm";
        string path = Server.MapPath("./" + filename);
        string content = System.IO.File.ReadAllText(path);
    
        return content;
    }
    
    // Populate Literal
    FrameLiteral.Text = GetFrameContent(arg);
    

    Not as elegant as doing it with user controls, but it should do the job and is relatively neat and tidy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC page that has left Menu Navigation that is built
I have an ASP.NET MVC Page that has Left Menu navigation that is built
I have a page that has 3 variables. They look like this: String[] Headers
I have a menu on the left of my page that is made of
I currently have an HTML page that has a grey BODY background. Now I
I have a problem with ViewState. I have an aspx page that has a
I have a page that has fields dynamically loaded via JQuery. It allows a
I have a page that has 2 columns of words, 20 total, that are
I have a page that has a bunch of user controls on it. I
I have a page that has a large image on it with a number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.