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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:16:40+00:00 2026-05-31T16:16:40+00:00

I have a setup, something confusing like this: <ListView> <ItemTemplate> <div id=Content> <asp: TextBox

  • 0

I have a setup, something confusing like this:

<ListView>
    <ItemTemplate>
        <div id="Content">
            <asp: TextBox ID="OuterTextBox" />
            <div id="Controls">
                <asp: ComboBox ID="InnerComboBox"/>
            </div>
            <div>
                <asp: Button ID="Submit" />
            </div>
        </div>
    </ItemTemplate>
<ListView>

Wonky I know, this is just a mockup. The real thing is worse. This is an ItemTemplate so this is obviously going to dynamically generate IDs when the page is compiled. What I’m trying to do is use jquery to create an object that starts at the level of the div labeled “Content”, then search all of it’s children (recursively) to find the value of each specified control. In this example, they are OuterTextBox and InnerComboBox. What is confusing me is the ridiculous hierarchy of elements. How do I do this the most efficiently? I can only assume that shortly down the road, there will be changes to the hierarchy of divs, so I’m hoping to get something that won’t break as soon as I move something, so explicit paths to the controls aren’t going to work. Here is the concept I’m currently trying to expand on:

function ClientIDS(obj) {

   var txt = $(obj).prevAll('input[id*="txtTextBox"]:first');
   alert($(txt).val());

   return false;
} 

I would then do something like OnClientClick=”ClientIDS(this)” in the server control.

This code is simple and clean, and worked perfectly when all of the controls were in the same div (as siblings). Can anyone come up with a way to find the controls in a similar, simple fashion to this when the controls get broken up by divs like this?

  • 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-31T16:16:41+00:00Added an answer on May 31, 2026 at 4:16 pm

    The usual way you find other items in the same container as you, but not necessarily siblings is to use .closest() to find the desired common ancestor constainer and then use .find() to find the actual element you’re looking for in that container using class names.

    I’m not sure exactly where your click starts, but lets say you had multiple items that came from this itemTemplate that I’ve modified to have a few classes:

    <ListView>
        <ItemTemplate>
            <div class="Content">
                <asp: TextBox ID="OuterTextBox" class="textbox"/>
                <div id="Controls">
                    <asp: ComboBox ID="InnerComboBox"/>
                </div>
                <div>
                    <asp: Button ID="Submit" />
                </div>
            </div>
        </ItemTemplate>
        <ItemTemplate>
            <div class="Content">
                <asp: TextBox ID="OuterTextBox" class="textbox"/>
                <div id="Controls">
                    <asp: ComboBox ID="InnerComboBox"/>
                </div>
                <div>
                    <asp: Button ID="Submit" />
                </div>
            </div>
        </ItemTemplate>
    <ListView>
    

    Then, from the submit button, you could use:

    $(this).closest(".Content").find(".textbox")
    

    And that would give you the textbox that was in the same container as the button that was clicked on.

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

Sidebar

Related Questions

I have something like this set up: class CategoryPage (webapp.RequestHandler): def get(self): ** DO
I currently have my PHP class variables set up like this: class someThing {
As most production environments we have setup something to send us a notification if
I have setup a property and implement INotifyPropertyChanged like so... public event PropertyChangedEventHandler PropertyChanged;
I have a custom search control on my page (asp.net) which contains a textbox
How can I search something using Solr? I have setup the Solr server in
I have setup a project in node with the express framework. I like that
I'm trying to multithread something and i have my program set up such that
I have setup web dav on windows server 2008. It seems to work fine
I have setup svnserve and for now now I am testing a repository with

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.