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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:13:46+00:00 2026-06-07T00:13:46+00:00

Ok so I am very new to html and the web. Right now I

  • 0

Ok so I am very new to html and the web. Right now I am trying to generate list items on the fly and then have them post back to the web server so I know what the person is trying to obtain.

Here is the code for generating the list items:

foreach (var item in dataList) {
    MyDataList.InnerHtml += "<li><a runat='server' onclick='li_Click' id='" + item.Name + "-button'></a></li>";
}

Further down I have my click event.

protected void li_Click(object sender, EventArgs e) {
    //How do I determine here which item was actually clicked?
}

My question is how do I determine which list item was clicked?

Btw, the code running behind is C#.

EDIT 1

LinkButton link = new LinkButton();
link.ID = "all-button";
link.Text = "All";
link.Click += new EventHandler(link_Click);
MyDataList.Controls.Add(link);

Then below I have my link_Click event that never seems to hit a breakpoint.

void link_Click(object sender, EventArgs e) {
    if (sender != null) {
        if (sender.GetType() == typeof(LinkButton)) {
            LinkButton button = (LinkButton)sender;
            if (button.ID == "all-button") {

            }
        }
    }
}

I know this has to be possible I just cant figure out what I am missing.

Edit 2

Ok ok I think I know what the problem is. I was trying to add a second list inside of another list. This was causing the whole thing to have problems. It is working now.

  • 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-06-07T00:13:47+00:00Added an answer on June 7, 2026 at 12:13 am

    Here is an example using LinkButtons.

    Code Behind:

    for (int i = 0; i < 10 ; i++)
    {
        LinkButton link = new LinkButton() { ID = "link_" + i };
        link.Text = "Link " + i;
        link.Click+=new EventHandler(link_Click);
        this.Form.Controls.Add(link);
    }
    
    protected void link_Click(object sender, EventArgs e)
    {
        //Every time a link is clicked it will get here in the server side
    }
    

    Good luck!

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

Sidebar

Related Questions

I'm trying to create my personal HTML site (I'm very new in web-site development).
Hi I'm very new to web development but have a coding background. I'm trying
I am very new to WordPress. I have converted a HTML website I created
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
Very new to web programming still and I don't really have a specific question
Hy! I am very new in Web-Dev. I have a mysql db and the
I'm very new to web development, have many years background on the desktop, but
I'm very new to Web programming and am trying to write a simple application
Very new to javascript and html-type stuff. I wanted to just make a quick
I am very new to MVC. I've been learning to use plain HTML or

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.