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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:12:30+00:00 2026-05-25T00:12:30+00:00

I’m CSSing my project and would like to customize the font color for the

  • 0

I’m CSSing my project and would like to customize the font color for the feedback label. My project is built in 3 layers (DAL, BLL, normal page). In the BLL I catch exceptions and I guess this is where I would add the CSS stylesheet reference. Unfortunately, I can’t get it to work, this is what it looks like.

BLL

Public Function deleteCustByCustID(ByVal CustID As Integer) As Boolean
    If dataCust.DeleteCust(Cust) Then
        Throw New Exception("The customer was removed.")
        Return True
    Else
        Throw New Exception("The customer wasn't removed. Please try again.")
        Return False
    End If
End Function

ASPX.vb page

Try
    bllCust.deleteCustByCustID(CustID)
Catch ex As Exception
    lblFeedback.Text = ex.Message
End Try

I have my CSS pages stored in a CSS folder. I would like to assign the font color lime to a success and the font color red to a failure.

Any help is much appreciated!

  • 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-25T00:12:31+00:00Added an answer on May 25, 2026 at 12:12 am

    Another option: if you have assigned an ID value to the markup for your “feedback” area, and if you added a runat="server" to that element, you can access the CssClass property in your code-behind file.

    By way of example:

    Markup

    <div id="Feedback" runat="server"></div>
    

    Code

    Me.Feedback.CssClass="error"
    

    Then you can use the CSS rules denoted by @rockerest in his answer.

    EDIT:

    Okay, I looked at your code again, and I see a big problem: you should NEVER use exceptions as a method of controlling program flow. That is probably error #1.

    A not-too-uncommon method of returning a more meaningful result from your methods is to encapsulate a result object. Here is a simple example:

    Public Class Result
    
        Public IsValid As Boolean
        Public Message As String
    
        Public Sub New(ByVal isValid As Boolean, ByVal message As String )
            IsValid = isValid
            Message = message
        End Sub
    
    End Class
    

    You would amend your current function to return a Result object instead of Boolean, and assign the values of the Result object depending on your query results:

    Public Function deleteCustByCustID(ByVal CustID As Integer) As Result
        Dim result as New Result
    
        If dataCust.DeleteCust(Cust) Then
            result = new Result( true, "The customer was removed." )
        Else
            result = new Result( false, "The customer wasn't removed. Please try again." )
        EndIf
    
        Return result
    
    End Function
    

    Then, in whatever code calls the deleteCustByCustID method, you assign the Message property to the content of the feedback area and the CssClass that matches the IsValid state.

    Make sense?

    EDIT 2:

    Okay, assuming you have a CSS class for errors, “.error” and a CSS class for, uh, not errors, “.success”. Then, let’s pretend the following snippet was inside an event handler or somesuchthing:

    Dim result As new Result = deleteCustByCustID( 42 )
    

    Now you have a Result object that has a IsValid state value (it will be either true or false) and a Message string value. Your next step is to apply the message to the feedback element’s (I’ll assume here that you use an ASP.NET Label control) Text property, and then, based on the value of result.IsValid, assign the correct class to the label’s CssClass property:

    myFeedbackLabel.Text = result.Message
    If result.IsValid Then
        myFeedbackLabel.CssClass = "success"
    Else
        myFeedbackLabel.CssClass = "error"
    EndIf
    

    HTH.

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

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.