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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:12:29+00:00 2026-05-26T06:12:29+00:00

I am trying to build a dropdown as below. I am generating html ul

  • 0

I am trying to build a dropdown as below.

this is the menu that I need to generate

I am generating html ul & li tags as below and works fine. However, everytime there is an anch tag (see the in-line comment); I need to be able to call a function and pass a text that was clicked. How can I do this?

        foreach (var productType in productTypesNames.Keys)
        {
            var li = new HtmlGenericControl("li");
            nav.Controls.Add(li);
            var ul = new HtmlGenericControl("ul");

            var anchor = new HtmlGenericControl("a");
            anchor.Attributes.Add("href", "#");

            foreach (var pName in productTypesNames[productType] )
            {
                var subLi = new HtmlGenericControl("li");
                var anch = new HtmlGenericControl("a");
                anch.Attributes.Add("href", "#");
                //**THIS NEEDS TO CALL A C# FUNCTION AND PASS pName; instead of #**
                anch.InnerHtml = pName;
                subLi.Controls.Add(anch);
                ul.Controls.Add(subLi);
            }
            anchor.InnerHtml = productType;
            li.Controls.Add(anchor);
            li.Controls.Add(ul);
        }
  • 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-26T06:12:30+00:00Added an answer on May 26, 2026 at 6:12 am

    If you don’t mind a postback, or want it, use a LinkButton control, easily built dynamically instead of your HtmlGenericControl("a"), and have the server-side onclick method call your other method.

    Otherwise you need AJAX as others have explained.

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

Sidebar

Related Questions

I am trying to build a dropdown list for a winform interop, and I
I'm trying to build an AutoComplete DropDown List that will work on a Mobile
I'm trying to get values from numerous dropdown lists and build a where statement
I am trying to build a CSS dropdown menu. The problem is that all
I'm trying to build a jquery dropdown menu, basically I have the left navigation
I am trying to build a fancy jquery dropdown menu ,while making the menu
I'm trying to build my own custom dropdown menu that should remember it's vertical
I'm trying to build a select-box like custom dropdown that should close whenever I
hey guys, I'm trying to build a simple custom select box with jquery. html:
I'm new to WPF and I'm trying to build a dropdown menu using the

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.