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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:01:50+00:00 2026-05-20T03:01:50+00:00

I am converting an old script from ASP to ASP.NET and would like some

  • 0

I am converting an old script from ASP to ASP.NET and would like some advice. The original ASP script used Response.Write to output information about what happened during execution. I have rewritten the entire thing in ASP.NET but it is new to me as an old-school C programmer. The job requirements include using the VB flavor of ASP.NET, btw.

I originally put up a TextBox and edited the text property to dump my final report. Now they want different colors for different message importance and I find that the TextBox can only do one color for all lines. I fell back to the old standby R.W but I get a message that it’s not declared and from looking around I see that it’s an issue because I’m calling it from the code behind and that is ‘out of scope’ from the HTML elements of the page itself.

My question is what is the best way to output information to the web page with different lines being different colors from a page’s code-behind?

Secondary question – if I have misunderstood anything feel free to correct my thinking. 🙂

Thanks!

  • 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-20T03:01:50+00:00Added an answer on May 20, 2026 at 3:01 am

    Literal is the correct approach in my opinion too, to prevent messiness you can wrap it nicely with some functions.

    First, have one literal control that will be the messages placeholder:

    <asp:Literal id="litMessages" runat="server" />
    

    Second, use CSS for the colors it’s more elegant and flexible.. for example:

    <style type="text/css">
    .msg_information { color: blue; }
    .msg_error { color: red; }
    .msg_warning { color: purple; }
    </style>
    

    Now have this function:

    void AddMessage(string message, string type)
    {
       string strHTML = string.Format("<div class=\"msg_{0}\">{1}</div>", type, message);
       litMessages.Text += strHTML;
    }
    

    And finally to add message have such code anywhere in your code:

    AddMessage("method started successfully", "information");
    AddMessage("Failed to do this: " + someErrorMessage, "error");
    AddMessage("Value is empty", "warning");
    

    You can make it even more elegant by using enum for message type and more, but the above is enough for basic needs. 🙂

    By having each message in its own <div> you make it be in its own line automatically and you can control each message easier with CSS.

    Edit: my code is C# but can be converted easily to VB.NET as well.

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

Sidebar

Related Questions

No related questions found

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.