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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:27:44+00:00 2026-05-19T12:27:44+00:00

I need to know how to do what the following would intuitively do if

  • 0

I need to know how to do what the following would intuitively do if it worked (imagine useGreek() and useNato() to be states that would be consulted once per load or postback):

<asp:radioButtonList id="rbl" runat="server" autoPostBack="true">
    <asp:listItem value="alpha" text="Alpha" />
    <% if(useGreek()) { %>
        <asp:listItem value="beta" text="Beta" />
        <asp:listItem value="gamma" text="Gamma" />
    <% } else if(useNato()) { %>
        <asp:listItem value="bravo" text="Bravo" />
        <asp:listItem value="charlie" text="Charlie" />
    <% } %>
    <asp:listItem value="delta" text="Delta" />
</asp:radioButtonList>

(It will already be apparent that I’m not usually asked to write for IIS.)

Anyway, ASP.NET doesn’t like code interleaved with list items, so this is a no-go. I imagine that there’s some C#-based way to handle this somehow, but I’ve been trying for a few days now with no luck.

Also, just to be clear, I’m seeking a server-side solution here. I’m well-versed with jQuery, but we’re trying to keep most of the processing of this particular form off the client.

Thanks, and party on.

  • 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-19T12:27:45+00:00Added an answer on May 19, 2026 at 12:27 pm

    No C# but i think you understand what i mean:

    in codebehind’s page_load:

    If Not IsPostBack Then
        Me.rbl.Items.Add(New ListItem("Alpha", "alpha"))
        If (useGreek()) Then
            Me.rbl.Items.Add(New ListItem("Beta", "beta"))
            Me.rbl.Items.Add(New ListItem("Gamma", "gamma"))
        ElseIf (useNato()) Then
            Me.rbl.Items.Add(New ListItem("Bravo", "bravo"))
            Me.rbl.Items.Add(New ListItem("Charlie", "charlie"))
        End If
        Me.rbl.Items.Add(New ListItem("Delta", "delta"))
    End If
    

    If you have to check on every postback because the state could change fast, you could add an Me.rbl.Items.Clear() to the top and remove the PostBack-check.

    EDIT:
    C#

    if (!IsPostBack) {
        this.rbl.Items.Add(new ListItem("Alpha", "alpha"));
        if ((useGreek())) {
            this.rbl.Items.Add(new ListItem("Beta", "beta"));
            this.rbl.Items.Add(new ListItem("Gamma", "gamma"));
        } else if ((useNato())) {
            this.rbl.Items.Add(new ListItem("Bravo", "bravo"));
            this.rbl.Items.Add(new ListItem("Charlie", "charlie"));
        }
        this.rbl.Items.Add(new ListItem("Delta", "delta"));
    }
    

    Because i’m not sure if you already know the codebehind model, have a look at following link:
    MSDN: Codebehind and Compilation in ASP.NET 2.0

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

Sidebar

Related Questions

I need to know how one would put the following JSON into elements with
I would need to know what is my final URL when following redirections using
I would like to know the following please: 1) I need, for an application
I need to know the default port settings for the following services SQL Server
I'm thinking of implementing something like the following and would like to know a)
I need to know about Epoll On linux System. Could you recommend manual or
I need to know how the performance of different XML tools (parsers, validators, XPath
I need to know how much space occupies all the databases inside an SQL
I need to know how to turn on Code Coverage when running TFS builds
I need to know when the memory will be allocated for a particular program.

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.