PC Review


Reply
Thread Tools Rate Thread

Control array in design time

 
 
Igor
Guest
Posts: n/a
 
      2nd Jan 2007
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?


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      2nd Jan 2007
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" <(E-Mail Removed)> wrote in message
news:endbk2$e86$(E-Mail Removed)...
> 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?
>
>



 
Reply With Quote
 
Igor
Guest
Posts: n/a
 
      2nd Jan 2007
"Eliyahu Goldin" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> No, there is no such a thing.


Oh, ****! It means that .NET is not better in every segment than vb6!


 
Reply With Quote
 
DeveloperX
Guest
Posts: n/a
 
      2nd Jan 2007
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" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
> > No, there is no such a thing.

>
> Oh, ****! It means that .NET is not better in every segment than vb6!


 
Reply With Quote
 
Igor
Guest
Posts: n/a
 
      2nd Jan 2007
"DeveloperX" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?


 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      2nd Jan 2007
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" <(E-Mail Removed)> wrote in message
news:endpfi$530$(E-Mail Removed)...
> "DeveloperX" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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?
>
>



 
Reply With Quote
 
DeveloperX
Guest
Posts: n/a
 
      2nd Jan 2007
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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?


 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      3rd Jan 2007
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" <(E-Mail Removed)> schreef in bericht
news:endpfi$530$(E-Mail Removed)...
> "DeveloperX" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How create label array at design time? Ronald S. Cook Microsoft C# .NET 1 3rd Jul 2007 02:20 AM
Control array in design time Igor Microsoft ASP .NET 7 3rd Jan 2007 06:01 AM
Control array in design time Igor Microsoft VB .NET 7 3rd Jan 2007 06:01 AM
Delete events/procedures of control if control is deleted at design time in VB.Net 2005 ? Luqman Microsoft VB .NET 1 30th Jun 2006 08:15 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com Microsoft ASP .NET 0 1st Jul 2003 10:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:28 AM.