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

  • Home
  • SEARCH
  • 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 a page base class that has no .aspx file and so I
I have a page that has an iframe From one of the pages within
I have a Page that has a single instance of a UserControl that itself
In a web application, I have a page that contains a DIV that has
We have a page that ordinarily has two elements arranged side-by-side. Despite exploring a
I have a login page that has several textboxes on the page, one of
On my C# asp.net webform I have a search page that has roughly 20
I have an XHTML strict page that has an invisible div that is controlled
If I have a control on a page that has its Datasource set to
I have a page with a Google Maps mashup that has pushpins that are

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.