473,666 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

controls as variables

I have 10 hyperlinks on an .aspx page. Hyperlink1, hyperlink2, etc.
I want to reference them in a loop to set their visibility and targets.
What I think I want to do is
mylink = 'hyperlink' & i (i being 1 to 10)

and change the string into a hyperlink reference and then do
mylink.target = abc.aspx
mylink.visible = true

I'm an old FoxPro programmer, so I'm lost in finding help on
this.

TIA,
Marc Miller


Nov 18 '05 #1
2 862
1)Put them all into an array, and index into an array
2)Use FindControl method to get the individual hyperlink. This isn't all
that well performing, but may not matter in your case.

Btw, I recommend googling for questions like this, they've been answered
dozens of times.

"Marc Miller" <mm****@hotmail .com> wrote in message
news:O2******** ******@TK2MSFTN GP12.phx.gbl...
I have 10 hyperlinks on an .aspx page. Hyperlink1, hyperlink2, etc.
I want to reference them in a loop to set their visibility and targets.
What I think I want to do is
mylink = 'hyperlink' & i (i being 1 to 10)

and change the string into a hyperlink reference and then do
mylink.target = abc.aspx
mylink.visible = true

I'm an old FoxPro programmer, so I'm lost in finding help on
this.

TIA,
Marc Miller

Nov 18 '05 #2
Marc Miller wrote:
I have 10 hyperlinks on an .aspx page. Hyperlink1, hyperlink2, etc.
I want to reference them in a loop to set their visibility and targets.
What I think I want to do is
mylink = 'hyperlink' & i (i being 1 to 10)

and change the string into a hyperlink reference and then do
mylink.target = abc.aspx
mylink.visible = true


Look at the FindControl() method. Basically you can do a loop like so:

For i as Integer = 1 to 10
Dim hl as HyperLink = FindControl("Hy perLink" & i)
If Not hl is Nothing Then
hl.NavigateUrl = ...
...
End If
Next

Additionally, this article would be benefitial reading:
http://www.odetocode.com/Articles/116.aspx

hth

--

Scott Mitchell
mi******@4guysf romrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla. com!
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
312
by: Lalit | last post by:
Hi Friends, We are defining coding standards for our company. In MSDN i have seen that hungarian notation will not be used in naming of variables etc. What about the controls ? Should we eliminate prefixes from these also. What do u suggest? Thanks in Advance
1
6319
by: Will | last post by:
Hi all. I'm learning VB.Net and am developing a WinForms app. I'm trying to make an app that I will use to scan in one or more than on image. I want to use a tabbed interface to hold each image. Here's the code I'm using for testing purposes. I've got the code in the form's load event, but I think I'd have the same problems no matter where the code existed. Right now, the form has an empty tab control, everthing else is dynamic. <code>
4
2434
by: Tony W | last post by:
Hi, I am trying to write a simple application to retrieve data from the Windows registry and insert it into textboxs on a windows form. So far I have one namespace containing two classess. The first class handles the form generation - (this was done using GUI form designer).
9
1394
by: Rob Meade | last post by:
Hi all, I have a form which is programmatically created from reading values from a database table. There is a 'form' for each DocumentType - when I say form I mean as in a different form will be displayed depending on the DocumentType. If the querystring contains the DocumenType then the drop down menu is removed and a text box (readonly) is put in its place to show the users what
4
2089
by: Bass Pro | last post by:
Hi, I am creating textbox, radiobuttonlist and checkboxlist dynamically depending on data from a table. It is a questionnaire. I add the control on a Panel control during the 1st load_page event. Each question is displayed and answered, then result written to a SQL table. Then the next question is read from a table and displayed using the load_page event again. The questions display and function perfectly. The user anwers the question...
0
1035
by: ben | last post by:
I am having some difficulty in understanding how to deal with variables, session states, objects, user controls while attempting to develop a ASP.Net application. I have created several user controls which consist of dropdown and textbox controls on a panel. In order for one user control to access a control on another usercontrol, I have to change the WithEvents to "Protected Shared". That will allow a sub to access a control on a...
3
1031
by: steve | last post by:
Hi I've been wondering for a wile now if its possible to make an application were the user can make a form by inputting data in variables this by using VB.net Example The user gets a dataset and below a button make form varname ! Description ! Default value ! Max length ! typeval
11
8577
by: radders | last post by:
I've just started working through Sams publishing's "Teach yourself Visual C++ 4 in 21 days", using VC++ version 4.0 on a windows xp machine. My problem occurs when I attempt to add member variables to controls that I have added to a dialog box through the Class Wizard, Member Variables tab. I can only see the Control IDs of the two Push Button Controls that are initially created by the MFC App Wizard - Ok and Cancel, despite having deleted...
2
2205
by: =?Utf-8?B?VG9u?= | last post by:
Hello, I want to understand teh benefits of ajax technology. Does anyone has a good website where AJAX EXTENSIONS is worked out so I really understand it. There a 2 main questions: 1) How about the form load event. Why should it fire when I put a button in a update panel? Is this necessary and is only the other controls related to the update panel send back? Or the whole page (If this is true I really do not get it). But please answer...
11
1674
by: Web Search Store | last post by:
Hello, I set up a web page with 2 user controls. In classic asp, the first one did all the declarations, and the second one used the values, and could reset it. In ASP.Net so far I can't see how to relate them so this will work. This user control defines the properties:
0
8445
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8640
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.