Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Getting sequentially numbered object references in a loop

Posted on 2011-10-11
Medium Priority
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 vb.net?
Question by:nzinsli
  • 2
LVL 17

Accepted Solution

Carlos Villegas earned 2000 total points
ID: 36949197
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


Expert Comment

ID: 36949214
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
ID: 36949240
Yes, I'm assuming that because he says:
I have a series of numbered html server objects on my page...

Author Closing Comment

ID: 36949532
I knew I was forgetting something. Thanks! :)

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Integration Management Part 2
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

580 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