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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:22:49+00:00 2026-05-25T01:22:49+00:00

I’m using an ASP Repeater. In the <ItemTemplate> and the <AlternatingItemTemplate> there are, among

  • 0

I’m using an ASP Repeater. In the <ItemTemplate> and the <AlternatingItemTemplate> there are, among other labels, etc, 3 HTML buttons (<input type="button"...) that make different javascript/jquery calls when clicked. This is working fine.

Now, I want to dynamically show/hide these buttons based on a boolean that is bound to my Repeater. I know if I were using an ASP Button, that I could simply use something like:

Visible='<%# Eval(bMyBoolean) %>'

I tried switching my HTML buttons to ASP Buttons but then I couldn’t get the javascript calls to work correctly. I know you can wire up the Javascript calls in the code behind for each button (in the Repeater.ItemDataBound event), but I’m not sure how to do that in the code behind with my scenario. Here is an example of one of my HTML buttons:

<input type="button" id="myButton" value="Test" onclick="MyJavascriptFunction(this,'<%# CType(Container.DataItem, myClassObject).FirstName%>');" />

In the above example, I’m passing the FirstName value (which is a property of the class object I’m binding to the repeater) to my Javascript function.

To me, it seems like if I’m using an ASP Repeater, then it would make sense to use ASP Buttons, but I don’t know if it really makes a difference?

So, my question is: How can I either dynamically show/hide an HTML Button inside an ASP Repeater based on a boolean value that is bound to the repeater? Or, if that is a bad practice, how can I make a javascript call with an ASP Button, like the call above (referencing a value from the Repeater)?

Thanks in advance for any help/advice!

  • 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-25T01:22:50+00:00Added an answer on May 25, 2026 at 1:22 am

    you can dynamically output style information based on your boolean. Consider this:

    <itemTemplate>
        <input type='button' style='<%# getVisbility(Eval("MyBoolValue")) %>' 
               value='click me' />
    </itemTemplate>
    

    Then in your code, you’d have:

    protected function getVisibility(isVisible as boolean) as string 
       if isVisible then
         return "display:inline; "
       else
         return "display:none;"
       end if 
    end function 
    

    Now, if you wanted to perform a JavaScript call from the asp.net control, you have options as well:

    The simplest — but by no means best option, is to do inline JS:

    <itemTemplate>
       <asp:button runat="server" onclientClick="return confirm('click to submit');" 
                   text="Click!" />
    </itemTemplate>
    

    there are more complex options with the use of JQuery that would allow you to dynamically capture a click event, and determine the exact row of the repeater that you’re selecting for. One example of this is:

    <itemTemplate>
       <asp:button cssclass ='clickMe' runat="server" rel='<%# Eval("MyCol")%>' 
                   text="Click!" />
    </itemTemplate>
    

    Then the jquery code:

    $(".clickMe").click(function(){
      var myVal = $(this).attr("rel");
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I know there's a lot of other questions out there that deal with this
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.