Getting sequentially numbered object references in a loop

Posted on 2011-10-11
Last Modified: 2012-08-14
I have a series of numbered html server objects on my page... div1, div2, etc...How can I get a reference to one of them in each iteration of a loop?

With js, it would be...
getElementById('div' + x)...

Open in new window

But how is that done in
Question by:nzinsli
    LVL 17

    Accepted Solution

    Hello, in your code behind file you can use something like:
    For x As Integer = 1 To 10 ' 10 is an example
        Dim myControl As Control = Me.FindControl("div" & x)

    Open in new window

    LVL 5

    Expert Comment

    I think in VB.NET the objects would also have to have the attribute runat="Server" in order for yv989c's solution to work.
    LVL 17

    Expert Comment

    by:Carlos Villegas
    Yes, I'm assuming that because he says:
    I have a series of numbered html server objects on my page...

    Author Closing Comment

    I knew I was forgetting something. Thanks! :)

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now