473,549 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3974
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.orgwro te in
message news:uA******** ******@TK2MSFTN GP02.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.orgwro te in
message news:uA******** ******@TK2MSFTN GP02.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*****@operam ail.comwrote in message
news:11******** **************@ n51g2000cwc.goo glegroups.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*****@operam ail.comwrote in message
news:11******** **************@ n51g2000cwc.goo glegroups.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*****@operam ail.comwrote in message
news:11******** **************@ n51g2000cwc.goo glegroups.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*****@operam ail.comwrote in message
news:11******** **************@ n51g2000cwc.goo glegroups.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
6377
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. Name => MyTextbox to Name => MyTextbox(1) you could then copy this control array element and paste back onto form to
7
1513
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
8
2308
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! Problem is I commonly associated several other controls with the same index inside the event handler - eg a Directory listbox, Label, Checkbox, Textbox...
2
1233
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 follows: My RichTextBox control : Public Class Crtb
0
1015
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 follows: My RichTextBox control : Public Class Crtb
0
1079
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 follows: My RichTextBox control : Public Class Crtb
0
3242
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 time. If I type the code in the aspx manually it does get parsed correctly though. This is an example of the aspx code that gets parsed...
7
1611
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 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?
10
3740
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 datasource. I would like to use an existing class object. The examples I have found state that the class should be in the App_Code folder. However a WAP...
0
7459
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...
0
7967
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...
0
7819
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...
0
6052
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...
1
5377
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5097
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
772
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...

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.