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 7611389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:39:28+00:00 2026-05-31T01:39:28+00:00

I am trying to initialize a literal with a big sequence of html code.

  • 0

I am trying to initialize a literal with a big sequence of html code.
for example this is working just fine:

Literal1.Text.= "<ul><li>home<li/><ul/>";//just fine

But:
When i have more than one lines it doesn’t work:

Literal1.Text.= "<ul><li>home
                 </li></ul>";//error

I know a simple solution which is this:

Literal1.Text.= "<ul><li>home"+
                "</li></ul>";//nice but time wasting for many lines

But:
When i have 100 lines for example i don’t want to spend my time concatenating the strings.Is there any more practical solution?

Specifically my html code is the folowing:

    Literal1.Text.= "<ul id="nav">


<li class="current"><a href="http://www.webdesignerwall.com">Home</a></li>
<li><a href="http://www.ndesign-studio.com">People</a>

    <ul>
        <li><a href="http://www.ndesign-studio.com">Customers</a>
            <ul>
                <li><a href="http://www.ndesign-studio.com/portfolio">View</a></li>
                <li><a href="http://www.ndesign-studio.com/wp-themes">Edit</a></li>
                <li><a href="http://www.ndesign-studio.com/wallpapers">Print</a></li>
                <li><a href="http://www.ndesign-studio.com/tutorials">Delete</a></li>

            </ul>
        </li>
        <li><a href="http://www.webdesignerwall.com">Employees</a>
            <ul>
                <li><a href="http://www.ndesign-studio.com/portfolio">View</a></li>
                <li><a href="http://www.ndesign-studio.com/wp-themes">Edit</a></li>
                <li><a href="http://www.ndesign-studio.com/wallpapers">Print</a></li>
                <li><a href="http://www.ndesign-studio.com/tutorials">Delete</a></li>
            </ul>
        </li>

    </ul>
</li>
<li><a href="#">Quotations</a>
    <ul>
        <li><a href="#">Create</a></li>
        <li><a href="#">Edit</a></li>
        <li><a href="#">View</a></li>



    </ul>
</li>   


<li><a href="#">Invoices</a>
    <ul>
        <li><a href="#">Create</a></li>
        <li><a href="#">Edit</a></li>
        <li><a href="#">View</a></li>



    </ul>
</li>   

<li><a href="#">Receipts</a>
    <ul>
        <li><a href="#">Create</a></li>
        <li><a href="#">Edit</a></li>
        <li><a href="#">View</a></li>


    </ul>
</li>   

<li><a href="#">Statements</a>
    <ul>
        <li><a href="#">Create</a></li>


    </ul>
</li>   

<li><a href="#">About Us</a></li>
<li class="style1"><a href="#">Contact Us</a></li>
</ul>";
  • 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-31T01:39:29+00:00Added an answer on May 31, 2026 at 1:39 am

    For a small number of lines of code, I generally use StringBuilder. That way there are no performance issues with concatenating large immutable strings.

    StringBuilder sb = new StringBuilder();
    
    sb.Add("<ul><li>home");
    sb.Add("</li></ul>");
    

    For a large number of lines, don’t put them in your code at all. Read them in using System.IO.File, so that you can edit your HTML without worrying about doubling your quotes. If you’re using the code a lot, read it in once using a static class so that you’re not causing a lot of extra IO usage. Something like this (untested):

    public static class HTMLStringClass
    {
        private static string html;
    
        public static string GetHtmlString()
        {
            if (string.IsNullOrEmpty(html))
                html = File.ReadAllText("path/to/file");
            return html;
        }
    }
    

    And then call it by doing this:

    Literal1.Text = HtmlStringClass.GetHtmlString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i'm trying to initialize a variable in my opencl host code like this:
I have this structure which i am trying to initialize using the following code.
I'm trying to initialize string with iterators and something like this works: ifstream fin(tmp.txt);
I'm trying to write a simple program in VC++ which will just initialize the
I am trying to initialize a ViewController from another. Here is the code written
I am trying to initialize a multidimensional array. Here is my syntax; this does
I'm trying to initialize a RDF datastore using Jena and HSQLDB . From http://jena.sourceforge.net/DB/hsql-howto.html
I'm trying to initialize a variable called proxy like this: proxy = Savon::Client.new http://192.168.1.1:8080
I am trying to initialize a generic collection List something like this: List<MyCustomClass> myCustomClassList
I'm trying to initialize a session but i get this error: Warning: session_start() [function.session-start]:

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.