473,399 Members | 3,401 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,399 software developers and data experts.

Adding a radion button at run time

I am trying to add a radio button at runtime in an asp.net web form
but I keep getting the error message "type 'RadioButton' must be
placed inside a form tag with runat=server". I use the following code:

Dim rbYes As New RadioButton()
dim sStyle as string

sStyle = "POSITION:absolute; TOP: 250px; LEFT: 10px"
rbYes.Attributes.Add("style", sStyle)
rbYes.Attributes.Add("runat", "server")
Me.Controls.Add(rbYes)

It is as if the rbYes.Attributes.Add("runat", "server") line is not
being executed. Any help would be great. Thanks

-Rob
Nov 18 '05 #1
3 1372
Hi, Rob,

Add the RadoiButton to the Controls collection of a PlaceHolder or a Panel
control that is already placed in the form of the page. In this way it will
end up inside the form.

Hope this helps
Martin
"Robert Bull" <ro*********@wbp.org> wrote in message
news:bf**************************@posting.google.c om...
I am trying to add a radio button at runtime in an asp.net web form
but I keep getting the error message "type 'RadioButton' must be
placed inside a form tag with runat=server". I use the following code:

Dim rbYes As New RadioButton()
dim sStyle as string

sStyle = "POSITION:absolute; TOP: 250px; LEFT: 10px"
rbYes.Attributes.Add("style", sStyle)
rbYes.Attributes.Add("runat", "server")
Me.Controls.Add(rbYes)

It is as if the rbYes.Attributes.Add("runat", "server") line is not
being executed. Any help would be great. Thanks

-Rob


Nov 18 '05 #2
you have two bugs.

1) rbYes.Attributes.Add("runat", "server")

does nothing useful, as the attribute is meanless to the browser. the
attribute is only used when parsing the apsx file.

2) you are adding the control after the form control, so its outside the
form, it will never postback.

you should put a place holder on the page, and add the control to the
placeholders control collection
-- bruce (sqlwork.com)


"Robert Bull" <ro*********@wbp.org> wrote in message
news:bf**************************@posting.google.c om...
I am trying to add a radio button at runtime in an asp.net web form
but I keep getting the error message "type 'RadioButton' must be
placed inside a form tag with runat=server". I use the following code:

Dim rbYes As New RadioButton()
dim sStyle as string

sStyle = "POSITION:absolute; TOP: 250px; LEFT: 10px"
rbYes.Attributes.Add("style", sStyle)
rbYes.Attributes.Add("runat", "server")
Me.Controls.Add(rbYes)

It is as if the rbYes.Attributes.Add("runat", "server") line is not
being executed. Any help would be great. Thanks

-Rob

Nov 18 '05 #3
Thanks Bruce...I used a panel instead and it worked great!

-Rob
Nov 18 '05 #4

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

Similar topics

3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
by: puja | last post by:
hi all, I have a form which has checkbox list which has items as below 1) Input 1 2) Input 2 3) Input 3 4) Input 4 5) Input 5
1
by: George Ter-Saakov | last post by:
I am trying to set class property of the radio button. but no mater what i do .NET moves it to <SPANtag aroung that radio button. So my <asp:RadioButton id="chkAllUpdates" cssClass="radio"...
6
Claus Mygind
by: Claus Mygind | last post by:
I have 3 radio buttons - isPartOf, isNotPartOf, and delete I do some onscreen subtotaling when the buttons are clicked. This a list of contacts and each contact has these 3 radio buttons with 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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
0
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...

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.