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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:40:18+00:00 2026-05-18T05:40:18+00:00

I have the following code in my page which works fine although the number

  • 0

I have the following code in my page which works fine although the number of cases is much much bigger. I need to use exactly the same list of cases in other selects but I don’t want to have exactly the same code duplicate all over the place.

I have this:

   Select Case Request.Cookies("LatestRefer").Value
        Case "EZ12"
            freeCallNumber = "0800 111 1111"
        Case "EW56"
            freeCallNumber = "0800 222 2222"
        Case "AT34"
            freeCallNumber = "0800 333 3333"
        Case Else
                freeCallNumber = "0800 444 4444"
    End Select

I ideally want something like this

Select Case Request.Cookies("cookie1").Value
            myGlobalListOfCases()
        End Select

Select Case Request.Cookies("cookie2").Value
                myGlobalListOfCases()
            End Select

Select Case Request.Cookies("cookie3").Value
                    myGlobalListOfCases()
                End Select

Any ideas?

EDIT:

Private Function getFreeCallNumber(ByVal value As String) As String
        Select Case value
            Case "EZ12"
                Return "0800 111 1111"
            Case Else
                Return "0800 222 2222"
        End Select
    End Function

And in the page_load:

If Not Request.Cookies("cookie1") is Nothing Then
    freeCallnumber = Me.getFreeCallNumber(Request.Cookies("cookie1").Value)
        Else
  freeCallnumber = Me.getFreeCallNumber(Request.Cookies("cookie2").Value)
        End If

This kind of works but there’s a slight problem. I have to load the page twice for the phone number to change (or the phone number appears as it should have done on the previous load). Hope this makes sense… it’s fairly odd behaviour.

  • 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-18T05:40:19+00:00Added an answer on May 18, 2026 at 5:40 am

    Create a method:

    private string getFreeCallNumber(string value)
    {
        switch (value)
        {
            case "EZ12":
                return "0800 111 1111";
            case "EW56":
                return "0800 222 2222";
            // TODO: Add more switch cases here.
            default:
                return null;
        }
    }
    

    When calling it:

    string freeCallnumber = this.getFreeCallNumber(Request.Cookies["cookie1"].Value));
    if (string.IsNullOrEmpty(freeCallNumber))
    {
         // other logic
    }
    

    My guess that it’s like this in VB.net:

    Private Function getFreeCallNumber(value as String) as String
        Select Case value
            Case "EZ12"
                return "0800 111 1111"
            Case "EW56"
                return "0800 222 2222"
            ' TODO: Add more switch cases here.
            Case Else
                return Nothing
        End Select
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQuery code: $(body.page-calendar-practices-2012-05 #content-header h1#title) which works fine. I can
I have the following code, which works fine: <input type=button name=btnHello value=Hello onclick=Test();/> and
I have the following code which works fine: // click on the button $(.btnHeaderSearch).click(function(event)
I have a master page in which I have the following code. <head runat=server>
I have the following code that works fine on my localhost using IIS7 but
I have the following code which pulls json data from an ASP.NET page and
I have folowing code in which i am using some conditions on page to
i have following code to show div on page <div id=all_users> <div id=user11 userid=11
I have following code. ASPX Page <a href=AnyASPXPageOfWebsite.aspx onclick=javascript:CallJQuery(); > Set Price </a> JS
I have the following code on my page. http://jsfiddle.net/SO_AMK/r7ZDm/ As you see it's a

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.