473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Control array in design time

Can I create control array (like TextBox array) in design mode. In vb6 I
drow some control at the form and then I copy/paste controls. After that
every control have the same name, but they have propetry index which is
position of this control in the array. Can I do this in asp.net or I must
create control array with code?
Jan 2 '07 #1
7 3220
No, there is no such a thing.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Igor" <ig**@igorovic.hrwrote in message
news:en**********@sunce.iskon.hr...
Can I create control array (like TextBox array) in design mode. In vb6 I
drow some control at the form and then I copy/paste controls. After that
every control have the same name, but they have propetry index which is
position of this control in the array. Can I do this in asp.net or I must
create control array with code?


Jan 2 '07 #2
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:uA**************@TK2MSFTNGP02.phx.gbl...
No, there is no such a thing.
Oh, shit! It means that .NET is not better in every segment than vb6!
Jan 2 '07 #3
They're very different beasts. What are you trying to achieve, perhaps
we could suggest an alternative approach with some more detail.

Igor wrote:
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:uA**************@TK2MSFTNGP02.phx.gbl...
No, there is no such a thing.

Oh, shit! It means that .NET is not better in every segment than vb6!
Jan 2 '07 #4
"DeveloperX" <nn*****@operamail.comwrote in message
news:11**********************@n51g2000cwc.googlegr oups.com...
They're very different beasts. What are you trying to achieve, perhaps
we could suggest an alternative approach with some more detail.
I make radiobutton array. Then user click on some radiobutton. After that
program must see which of these radiobuttons have property checked=true. but
every radiobutton have property false. Look at this:
Dim rb(0 To 2) As RadioButton
Dim n As Integer

For n = 0 To 2
rb(n) = New RadioButton
rb(n).Text = "Text: " + CStr(n)
rb(n).Groupname="Group1"
Panel1.Controls.Add(rb(n))
Next
Session("rb") = rb
Than I call this RadioButton array from session to other procedure:

Dim rb(0 To 2) As RadioButton
rb = Session("rb")
Response.Write(rb(0).Checked)
Response.Write(rb(1).Checked)
Response.Write(rb(2).Checked)
Problem is next: Every RadioButton have property Checked=False even when
user check some button. Text property is ok, but checked property is False
every time.

How to fix it?
Jan 2 '07 #5
The controls you restore from the session have nothing to do with the values
you are getting in postbacks. You don't need to use session. Since you
create the radiobuttons dynamically, you need to re-create them on every
postback and then they will pick up the posted values. A good practice is to
re-create the dynamic controls in the Init event.

Here is a good article:
Dynamic Web Controls, Postbacks, and View State
http://aspnet.4guysfromrolla.com/articles/092904-1.aspx

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Igor" <ig**@igorovic.hrwrote in message
news:en**********@sunce.iskon.hr...
"DeveloperX" <nn*****@operamail.comwrote in message
news:11**********************@n51g2000cwc.googlegr oups.com...
>They're very different beasts. What are you trying to achieve, perhaps
we could suggest an alternative approach with some more detail.

I make radiobutton array. Then user click on some radiobutton. After that
program must see which of these radiobuttons have property checked=true.
but every radiobutton have property false. Look at this:
Dim rb(0 To 2) As RadioButton
Dim n As Integer

For n = 0 To 2
rb(n) = New RadioButton
rb(n).Text = "Text: " + CStr(n)
rb(n).Groupname="Group1"
Panel1.Controls.Add(rb(n))
Next
Session("rb") = rb
Than I call this RadioButton array from session to other procedure:

Dim rb(0 To 2) As RadioButton
rb = Session("rb")
Response.Write(rb(0).Checked)
Response.Write(rb(1).Checked)
Response.Write(rb(2).Checked)
Problem is next: Every RadioButton have property Checked=False even when
user check some button. Text property is ok, but checked property is False
every time.

How to fix it?


Jan 2 '07 #6
I'm not sure how familiar you are with asp.net, but could this be a
postback/viewstate issue? Where is the first snippet of code called and
where/when is the second bit called? The asp bod's will know, but I'm
guessing your code is being called twice overwriting the checked button
with a new button.
The easy way to check is pop a breakpoint on the first and second bits
of code and see if the first is hit between you checking a button and
the second bit of code being called.

Igor wrote:
"DeveloperX" <nn*****@operamail.comwrote in message
news:11**********************@n51g2000cwc.googlegr oups.com...
They're very different beasts. What are you trying to achieve, perhaps
we could suggest an alternative approach with some more detail.

I make radiobutton array. Then user click on some radiobutton. After that
program must see which of these radiobuttons have property checked=true. but
every radiobutton have property false. Look at this:
Dim rb(0 To 2) As RadioButton
Dim n As Integer

For n = 0 To 2
rb(n) = New RadioButton
rb(n).Text = "Text: " + CStr(n)
rb(n).Groupname="Group1"
Panel1.Controls.Add(rb(n))
Next
Session("rb") = rb
Than I call this RadioButton array from session to other procedure:

Dim rb(0 To 2) As RadioButton
rb = Session("rb")
Response.Write(rb(0).Checked)
Response.Write(rb(1).Checked)
Response.Write(rb(2).Checked)
Problem is next: Every RadioButton have property Checked=False even when
user check some button. Text property is ok, but checked property is False
every time.

How to fix it?
Jan 2 '07 #7
Igor,

You create in fact an array of controls as soon as you put them in a
groupbox, panel or those kind of controls.

Here a little sample how to use it, although that is not about the control
array but more how to use the dynamicly. (Showing desing samples is always
difficult to do).

http://www.vb-tips.com/dbpages.aspx?...f-7587aff9c18b

I hope this helps,

Cor

"Igor" <ig**@igorovic.hrschreef in bericht
news:en**********@sunce.iskon.hr...
"DeveloperX" <nn*****@operamail.comwrote in message
news:11**********************@n51g2000cwc.googlegr oups.com...
>They're very different beasts. What are you trying to achieve, perhaps
we could suggest an alternative approach with some more detail.

I make radiobutton array. Then user click on some radiobutton. After that
program must see which of these radiobuttons have property checked=true.
but every radiobutton have property false. Look at this:
Dim rb(0 To 2) As RadioButton
Dim n As Integer

For n = 0 To 2
rb(n) = New RadioButton
rb(n).Text = "Text: " + CStr(n)
rb(n).Groupname="Group1"
Panel1.Controls.Add(rb(n))
Next
Session("rb") = rb
Than I call this RadioButton array from session to other procedure:

Dim rb(0 To 2) As RadioButton
rb = Session("rb")
Response.Write(rb(0).Checked)
Response.Write(rb(1).Checked)
Response.Write(rb(2).Checked)
Problem is next: Every RadioButton have property Checked=False even when
user check some button. Text property is ok, but checked property is False
every time.

How to fix it?


Jan 3 '07 #8

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

Similar topics

3
by: Mark Broadbent | last post by:
In VB6 (using visual studio) it was possible to create a control array at design time by simply adding the control (e.g. textbox) and renaming it to what would become the first element e.g. ...
7
by: Jacky Luk | last post by:
Does anyone know of a downloadable Line ActiveX control which allows me to plot straight lines on a VC++.NET form? Thanks Jack
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
8
by: Greg | last post by:
In VB6 I made heavy use of control arrays I see they have been 'deprecated' in vb.Net, with a questionable explanation that they are no longer necessary which just addresses the event issue!...
2
by: Allan Bredahl | last post by:
Hi all Im currently constructing a Windows control that inherits from RichTextBox, but I'm having a bit of trouble with updating the control at design time. The senario is SIMPLIFIED as...
0
by: Allan Bredahl | last post by:
Hi all Im currently constructing a Windows control that inherits from RichTextBox, but I'm having a bit of trouble with updating the control at design time. The senario is SIMPLIFIED as...
0
by: Allan Bredahl | last post by:
Hi all Im currently constructing a Windows control that inherits from RichTextBox, but I'm having a bit of trouble with updating the control at design time. The senario is SIMPLIFIED as...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
7
by: Igor | last post by:
Can I create control array (like TextBox array) in design mode. In vb6 I drow some control at the form and then I copy/paste controls. After that every control have the same name, but they have...
10
by: AG | last post by:
I am trying to use a ReportViewer control in a VS 2005 web application project (not Website project). When I try to create a new report (local), I can't seem to find any method to create a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.