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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:07:37+00:00 2026-05-27T13:07:37+00:00

I’m adding in asp.net (vb) an attribute to an image-button: imgButton.Attributes.Add(myAttr, true) This is

  • 0

I’m adding in asp.net (vb) an attribute to an image-button:

imgButton.Attributes.Add("myAttr", "true")

This is working fine.

Now i want to read the attribute, but it does not work:

If imgButton.Attributes("myAttr") = "true" Then
 ..doSomething..

How do I get this thing working?

Edit

I have an asp.net repeater.
In this repeater i have in each itemtemplate two image buttons.
If I’m clicking on an imagebutton, the other imagebutton in this row changes it’s URL.
I want that this URL is saved, after clicking on another row’s imagebutton.

So I’m adding in the repeater event
ItemCommand

Dim imgButton As ImageButton

    If e.CommandName = "imgBtn1" Then

        imgButton = CType(e.Item.FindControl("imgBtn1"), ImageButton)
        imgButton.ImageUrl = "myURL"
        imgButton.Attributes.Add("myAttr1", "true")

    ElseIf e.CommandName = "imgBtn2" Then

        imgButton = CType(e.Item.FindControl("imgBtn2"), ImageButton)
        imgButton.ImageUrl = "myURL"
        imgButton.Attributes.Add("myAttr2", "true")

    End If

In the Page Load event I’m adding:

If Page.IsPostBack Then
        Dim countRepeaterItems As Integer = myRepeater.Items.Count
        Dim imgButton As ImageButton

        For i As Integer = 0 To countRepeaterItems - 1
            imgButton = CType(myRepeater.Items(i).FindControl("imgBtn1"), ImageButton)
            If imgButton.Attributes.Item("myAttr1") = "true" Then
                imgButton.ImageUrl = "myURL"
            End If
            imgButton = CType(myRepeater.Items(i).FindControl("imgBtn2"), ImageButton)
            If imgButton.Attributes.Item("myAttr2") = "true" Then
                imgButton.ImageUrl = "myURL"
            End If
        Next

    End If

While debugging, it still skips everything, because all Attributes are empty (but actually they are not)!

  • 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-27T13:07:37+00:00Added an answer on May 27, 2026 at 1:07 pm

    I guess! May be you have (turn off the viewstate) set EnableViewState=False to the imgButton.

    Take a look at this sample:

    Markup:

    <form id="form1" runat="server">
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </form>
    

    Code:

         Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
            If Label1.Attributes("myAttr") = "true" Then
                Label1.Attributes.Add("myAttr", "false")
                Label1.Text = "false is set"
            Else
                Label1.Attributes.Add("myAttr", "true")
                Label1.Text = "true is set"
            End If
        End Sub
        Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                Label1.Attributes.Add("myAttr", "true")
            End If
        End Sub
    

    EDIT:

    May be typo in ItemCommand event code.

    imgButton.ImageUrl = "myURL"
     imgButton.Attributes.Add("myAttr1", "true") '<----- Correction
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.