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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:34:40+00:00 2026-05-21T21:34:40+00:00

I have a list in my aspx page where the values for the list

  • 0

I have a list in my aspx page where the values for the list are coming from the database. The data can be added to the list successfully

But how can I retrieve the value of the selected list item when I click on that? (ul_Click event)

I don’t want to redirect to another page because I’m using AJAX. so i want it in the same page. that’s why i commented the

    <ul runat="server" id="ulList" onclick="ul_Click">
    </ul>

The data is binded to the list in the page_load event.

protected void Page_Load(object sender, EventArgs e)
{
    conn = new SqlConnection("Server=NIPUNA-PC\\SQLEXPRESS; Database=XXX; Trusted_Connection=True");
    string[] itemList = authorList();
    foreach (string item in itemList)
    {
        HtmlGenericControl newLi = new HtmlGenericControl("li");
        //newLi.InnerHtml = "<a href=\"Books.aspx?bookId=" + item + "\">" + item + "</a>";
        newLi.InnerText = item;
        ulList.Controls.Add(newLi);
    }
}

I want the ul_Click() event?

  • 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-21T21:34:41+00:00Added an answer on May 21, 2026 at 9:34 pm

    seems like you were on track with the innerHtml thing. You can pass some kind of an ID with the link.

    "<a href=\"Books.aspx?bookId=" + item + "&liID=" + **SOME_ID** + "\">" + item + "</a>";
    

    then do a request querystring and check for that id. if it’s there, then call a function?

    i’m not 100% sure, but what you’re trying to do might be impossible otehrwise with HtmlGenericControl. I don’t think you can bind an onclick event to HtmlGenericControl

    Your other option is perhaps go with ajax/javascript

    EDIT> just saw the comment. so …. you might do something like

     "<a href=\"javascript:callMyAjaxFunction(" + item + ");\">" + item + "</a>";
    

    you could also do

    "<a href=\#"\" onclick=\"javascript:callMyAjaxFunction(" + item + ");\">" + item + "</a>";
    

    i personally dislike the last one as <a href="#" version because it can cause bad client side behavior such as to go to page top or something stupid like that when clicked.

    just to wrap things up. Keep in mind that you’ll need a client side javascript to handle the function

    <script language="javascript">
        function callMyAjaxFunction(bookid){
           // do something
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my .aspx page, I have a dropdown list. The first value that it
I have a UL list in a ASPX page: <ul id=tabs> <li id=tab1><a href=ztab1.htm>Tab
I have the list box control (ASP.NET Control On aspx page, language C# ).
Hello Friends I am using a list box control in aspx page i have
I have an aspx page with three web controls: one to control the List
I have successfully sent (username/password) and received (true/false) values from my android app to
In my aspx page I have drop down list that initialy in page load
I have dropdown list on my aspx page. I want to mannually set the
I have a main aspx page in which there is a list of items.
I have a this aspx-code: (sample) <asp:DropDownList runat=server ID=ddList1></asp:DropDownList> With this codebehind: List<System.Web.UI.WebControls.ListItem> colors

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.