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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:06:41+00:00 2026-05-25T03:06:41+00:00

private const string CurrentPageCssClass = important; private void HidhLightCurrentPageIndex() { switch (tpMain.ActiveTabIndex) { case

  • 0
 private const string CurrentPageCssClass = "important";
        private void HidhLightCurrentPageIndex() {

            switch (tpMain.ActiveTabIndex) {
                case 0:
                    elblFirst.AddClass(CurrentPageCssClass);
                    elblSecond.RemoveClass(CurrentPageCssClass);
                    elblThird.RemoveClass(CurrentPageCssClass);
                    elblFouth.RemoveClass(CurrentPageCssClass);
                    elblFirth.RemoveClass(CurrentPageCssClass);
                    break;
                case 1:
                    elblFirst.RemoveClass(CurrentPageCssClass);
                    elblSecond.AddClass(CurrentPageCssClass);
                    elblThird.RemoveClass(CurrentPageCssClass);
                    elblFouth.RemoveClass(CurrentPageCssClass);
                    elblFirth.RemoveClass(CurrentPageCssClass);

                    break;
                case 2:
                    elblFirst.RemoveClass(CurrentPageCssClass);
                    elblSecond.RemoveClass(CurrentPageCssClass);
                    elblThird.AddClass(CurrentPageCssClass);
                    elblFouth.RemoveClass(CurrentPageCssClass);
                    elblFirth.RemoveClass(CurrentPageCssClass);


                    break;
                case 3:
                    elblFirst.RemoveClass(CurrentPageCssClass);
                    elblSecond.RemoveClass(CurrentPageCssClass);
                    elblThird.RemoveClass(CurrentPageCssClass);
                    elblFouth.AddClass(CurrentPageCssClass);
                    elblFirth.RemoveClass(CurrentPageCssClass);
                    break;
                case 4:
                    elblFirst.RemoveClass(CurrentPageCssClass);
                    elblSecond.RemoveClass(CurrentPageCssClass);
                    elblThird.RemoveClass(CurrentPageCssClass);
                    elblFouth.RemoveClass(CurrentPageCssClass);
                    elblFirth.AddClass(CurrentPageCssClass);
                    break;

            }
        }

Does anybody have any suggestions for how to simplify this code?

  • 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-25T03:06:42+00:00Added an answer on May 25, 2026 at 3:06 am

    Put the controls in an array, then call RemoveClass on all the elements, and then AddClass on the active element.’

    Edit: Code

    var controls = new[] { elblFirst, elblSecond, elblThird, elblFourth, elblFifth };
    foreach (var control in controls)
    {
        control.RemoveClass(CurrentPageCssClass);
    }
    
    controls[tpMain.ActiveTabIndex].AddClass(CurrentPageCssClass);
    

    Of course this is assuming that an additional call to RemoveClass has a negligible cost, otherwise use a regular for loop and skip the active index.

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

Sidebar

Related Questions

class String { private: char* rep; public: String (const char*); void toUpper() const; };
Its quite annoying. Example: private const string someUrl = http://foo.com; I don't want the
public sealed class IntegerBox : TextBox { #region constants private const string RangeConstraintValidatorID =
I have a class like this: public class SomeClass { private const string sessionKey
This code is not valid: private void Foo(string optionalString = string.Empty) { // do
private const String FormatOverrideCols = <XmlDS><table1><col1>Value1</col1></table1><table1><col1>Value2</col1></table1></XmlDS>; System.IO.StringReader xmlSR = new System.IO.StringReader(FormatOverrideCols); ds.ReadXml(xmlSR, XmlReadMode.IgnoreSchema); Why
In this snippet: class ClassWithConstants { private const string ConstantA = Something; private const
I have a string that I use for client side validation: private const String
There is some code: private const string FORMAT_TEXT = {timestamp}: [{category} ({win32ThreadId}-{threadName}) {severity}] |{title}|:
// stuff...... return SendCreationMail(Membership.GetUser((Guid)request.UserEntityId), request, new Control()); } private const string TemplateRoot = ~/app_shared/templates/mail/;

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.