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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:36:25+00:00 2026-05-29T15:36:25+00:00

I’m creating <div> ‘s and appending them to a literal’s text property. I have

  • 0

I’m creating <div>‘s and appending them to a literal’s text property. I have added a <a> element to the text so that the user can click on a specific element. How can I tie that to a function to handle the event in the codebehind (vb.net) ?

Example of my Literal.Text …

    For Each row As DataRow In oDataTable.Rows
       MyLiteral.Text &= "<div style='font-size: 8.25px; text-transform:uppercase; padding:3px; background: #FF8C00; border: 1px solid #000; margin: 0 5px 0 5px; display:inline-block; float: left;'>" _
                         & row.Item("LastName") & " | <a href='#?"& row.Item("ID") & "' style='color: #000;' >X</a></div>"
    Next

So the above code I want to somehow allow the user to click the X link and then it would remove that person.

Edit: If there is a better way of doing this, that would be great to hear also! Thanks.

  • 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-29T15:36:26+00:00Added an answer on May 29, 2026 at 3:36 pm

    Why not switch to using an asp:Repeater control. From there you can add a asp:LinkButton to the repeater template and capture the post back. The Repeater control was designed to do the same thing you’re doing with your loop, that being create a template to be used with collection of data. This will enable the use of controls with a runat=”server” to handle postback events.

    Here are some pages that discuss using the Repeater:

    http://www.aspnettutorials.com/tutorials/controls/repeater-vb.aspx

    http://www.dotnetcurry.com/ShowArticle.aspx?ID=663

    You’ll likely want to use the OnItemDataBound event to handle your controls that are runat=”server”:

    fetching values from the repeater control in ItemDataBound event

    http://www.codeguru.com/csharp/.net/net_asp/tutorials/article.php/c12065

    And articles about how to handle the button click postback event:

    button event in nested repeater

    ASP.Net: why is my button's click/command events not binding/firing in a repeater?

    My VB.NET is rusty but I would be more than happy to help you with any questions you might have.

    EDIT – Adding code sample

    My repeater:

    <asp:Repeater runat="server" ID="repTemplate">
        <ItemTemplate>
            <div>
               <%# DataBinder.Eval(Container.DataItem, "Key")%> - <%# DataBinder.Eval(Container.DataItem, "Value") %>
               <asp:LinkButton OnClick="RepeaterLinkButton1_Click" runat="server" ID="linkDelete" Text="X" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Key") %>' />
            </div>
        </ItemTemplate>
    </asp:Repeater>
    

    And the code behind in the page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
    
        If IsPostBack = False Then
    
            Dim data As Dictionary(Of Integer, String) = New Dictionary(Of Integer, String)()
    
            data.Add(1, "Test #1")
            data.Add(2, "Test #2")
            data.Add(3, "Test #3")
            data.Add(4, "Test #4")
            data.Add(5, "Test #5")
    
            Me.repTemplate.DataSource = data
            Me.repTemplate.DataBind()
    
        End If
    
    End Sub
    
    Protected Sub RepeaterLinkButton1_Click(sender As Object, e As EventArgs)
    
        Dim linkButton As LinkButton = sender
        Dim id As String = linkButton.CommandArgument
    
        'TODO: Delete from the database based on ID
        'TODO: Reload the data to the repeater
    
    End Sub
    

    By setting the OnClick function in the HTML view of the code and setting the CommandArgument to the ID you can capture the ID of the row and do what ever you want. Keep in mind that my example is using a Dictonary for data as an example, so “Key” is the unique key of the item and “Value” is what ever is stored in it and thats why the HTML is using the “Key”/”Value” names.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.