473,396 Members | 1,940 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,396 software developers and data experts.

Control 'X' of type 'RadioButton' must be placed inside a form tag with runat=server.


I'm trying to create dynamic controls in ASP.Net. It's driving me
nuts. I keep getting the error:

Control '16' of type 'RadioButton' must be placed inside a form tag
with runat=server.

Dim Place1 As New PlaceHolder
Controls.Add(Place1)
For y = 1 To Choices.RecordCount
Choices.MoveTo(y)
Dim Radio As New RadioButton
Radio.ID = choices.ID
Radio.Text = choices.ChoiceText
Radio.GroupName = Q.ID
Place1.Controls.Add(Radio)

If I do Controls.Add(Radio) I get the above error. So I created a
placeholder in design view (there's nothing there since all page
content is dynamic). It added the radios but at the bottom of the
form. So I modified the code to dynamically create the placeholder
(as above). I STILL get this error.

Do I have to do a:
response.write("<FORM etc etc... runat=server>")
before every checbox creation?

Why doesn't it add the tags itself while its creating the controls?

How do I add a control without getting that needless error at every
turn?

Thanks!

Nov 19 '05 #1
7 6346
Hi Tom,

Try this instead of Controls.Add(Place1):

Me.FindControl("Form1").Controls.Add(Place1)

(provided your form is called Form1, obviously, but that's what it's
called by default).

You were adding the radiobuttons in the Page controls, but outside of
the Form controls.

Also note that "Me." is only here for demonstration purposes. You can
omit it, it's implicit.

HTH,

Michel

Tom wilson <ye*******@nospam.com> wrote in message news:<57********************************@4ax.com>. ..
I'm trying to create dynamic controls in ASP.Net. It's driving me
nuts. I keep getting the error:

Control '16' of type 'RadioButton' must be placed inside a form tag
with runat=server.

Dim Place1 As New PlaceHolder
Controls.Add(Place1)
For y = 1 To Choices.RecordCount
Choices.MoveTo(y)
Dim Radio As New RadioButton
Radio.ID = choices.ID
Radio.Text = choices.ChoiceText
Radio.GroupName = Q.ID
Place1.Controls.Add(Radio)

If I do Controls.Add(Radio) I get the above error. So I created a
placeholder in design view (there's nothing there since all page
content is dynamic). It added the radios but at the bottom of the
form. So I modified the code to dynamically create the placeholder
(as above). I STILL get this error.

Do I have to do a:
response.write("<FORM etc etc... runat=server>")
before every checbox creation?

Why doesn't it add the tags itself while its creating the controls?

How do I add a control without getting that needless error at every
turn?

Thanks!

Nov 19 '05 #2
When I add that line I get "Object reference not set to..." I've
tried it on its own page with nothing else but this:

Dim Place1 as new Placeholder
me.FindForm("TestForm").Controls.Add(Place1)

Same result. I have discovered that I can add a placeholder in design
view and it will accept control additions. I guess the whole problem
is that I cannot create a placeholder dynamically within the form
tags. I don't know why something so simple has to be so complicated.

On 8 Feb 2005 23:56:10 -0800, fd******@hotmail.com (fd123456) wrote:
Hi Tom,

Try this instead of Controls.Add(Place1):

Me.FindControl("Form1").Controls.Add(Place1)

(provided your form is called Form1, obviously, but that's what it's
called by default).

You were adding the radiobuttons in the Page controls, but outside of
the Form controls.

Also note that "Me." is only here for demonstration purposes. You can
omit it, it's implicit.

HTH,

Michel

Tom wilson <ye*******@nospam.com> wrote in message news:<57********************************@4ax.com>. ..
I'm trying to create dynamic controls in ASP.Net. It's driving me
nuts. I keep getting the error:

Control '16' of type 'RadioButton' must be placed inside a form tag
with runat=server.

Dim Place1 As New PlaceHolder
Controls.Add(Place1)
For y = 1 To Choices.RecordCount
Choices.MoveTo(y)
Dim Radio As New RadioButton
Radio.ID = choices.ID
Radio.Text = choices.ChoiceText
Radio.GroupName = Q.ID
Place1.Controls.Add(Radio)

If I do Controls.Add(Radio) I get the above error. So I created a
placeholder in design view (there's nothing there since all page
content is dynamic). It added the radios but at the bottom of the
form. So I modified the code to dynamically create the placeholder
(as above). I STILL get this error.

Do I have to do a:
response.write("<FORM etc etc... runat=server>")
before every checbox creation?

Why doesn't it add the tags itself while its creating the controls?

How do I add a control without getting that needless error at every
turn?

Thanks!


Nov 19 '05 #3
Couple things.

1. What is your page derived from to have a FindForm method?
2. Your form is probably called frmTestForm.

me.FindControl( "frmTestForm" ).Controls.Add( Place1 )

It really isn't that complicated; it is simply a matter of learning the
framework. Although I do wish MS would have exposed the internal Form
property they have. Perhaps this will be modified in 2.0.

bill

"Tom wilson" <ye*******@nospam.com> wrote in message
news:er********************************@4ax.com...
When I add that line I get "Object reference not set to..." I've
tried it on its own page with nothing else but this:

Dim Place1 as new Placeholder
me.FindForm("TestForm").Controls.Add(Place1)

Same result. I have discovered that I can add a placeholder in design
view and it will accept control additions. I guess the whole problem
is that I cannot create a placeholder dynamically within the form
tags. I don't know why something so simple has to be so complicated.

On 8 Feb 2005 23:56:10 -0800, fd******@hotmail.com (fd123456) wrote:
Hi Tom,

Try this instead of Controls.Add(Place1):

Me.FindControl("Form1").Controls.Add(Place1)

(provided your form is called Form1, obviously, but that's what it's
called by default).

You were adding the radiobuttons in the Page controls, but outside of
the Form controls.

Also note that "Me." is only here for demonstration purposes. You can
omit it, it's implicit.

HTH,

Michel

Tom wilson <ye*******@nospam.com> wrote in message news:<57********************************@4ax.com>. ..
I'm trying to create dynamic controls in ASP.Net. It's driving me
nuts. I keep getting the error:

Control '16' of type 'RadioButton' must be placed inside a form tag
with runat=server.

Dim Place1 As New PlaceHolder
Controls.Add(Place1)
For y = 1 To Choices.RecordCount
Choices.MoveTo(y)
Dim Radio As New RadioButton
Radio.ID = choices.ID
Radio.Text = choices.ChoiceText
Radio.GroupName = Q.ID
Place1.Controls.Add(Radio)

If I do Controls.Add(Radio) I get the above error. So I created a
placeholder in design view (there's nothing there since all page
content is dynamic). It added the radios but at the bottom of the
form. So I modified the code to dynamically create the placeholder
(as above). I STILL get this error.

Do I have to do a:
response.write("<FORM etc etc... runat=server>")
before every checbox creation?

Why doesn't it add the tags itself while its creating the controls?

How do I add a control without getting that needless error at every
turn?

Thanks!

Nov 19 '05 #4
1 - How do I find that out? The Class is called "TestForm". It
appears to inherit from "MyApp.TestForm". Is that what I need?
Not complicated? This is a re-write of a survey application
originally done in asp. For that method, it was as simple as one line
of HTML to create a textbox and response.write the text/html. With
this I have to:

1 - Manually add a placeholder to the empty form. I can't create one
dynamically, everyt method I've tried fails.

2 - Create a set of control arrays for each type of control; checkbox,
radio, etc.

3 - Redim Preserve each array as the number of controls increases as
they are created. I hope 500 radios don't eat too much memory.

4 - Create the control, takes about 5 lines of code not including the
array tracking.

5 - Add the newly created control to the placeholder.

....and everything must be a control. Text? HTML? They have to be
defined as LiteralControl(s) and added in sequence. I remember when
it was called "response.write" but if I do that, all the text is at
the top of the page and the controls underneath because response.write
doesn't add to a placeholder. I swear if I have to do tables my head
will explode.

Yes, it's that complicated.

Sorry about the rant, it's been 3 days at this with little progress.
I do very much appreciate your input.


On Wed, 9 Feb 2005 10:19:48 -0600, "William F. Robertson, Jr."
<th****@nameht.org> wrote:
Couple things.

1. What is your page derived from to have a FindForm method?
2. Your form is probably called frmTestForm.

me.FindControl( "frmTestForm" ).Controls.Add( Place1 )

It really isn't that complicated; it is simply a matter of learning the
framework. Although I do wish MS would have exposed the internal Form
property they have. Perhaps this will be modified in 2.0.

bill

"Tom wilson" <ye*******@nospam.com> wrote in message
news:er********************************@4ax.com.. .
When I add that line I get "Object reference not set to..." I've
tried it on its own page with nothing else but this:

Dim Place1 as new Placeholder
me.FindForm("TestForm").Controls.Add(Place1)

Same result. I have discovered that I can add a placeholder in design
view and it will accept control additions. I guess the whole problem
is that I cannot create a placeholder dynamically within the form
tags. I don't know why something so simple has to be so complicated.

On 8 Feb 2005 23:56:10 -0800, fd******@hotmail.com (fd123456) wrote:
>Hi Tom,
>
>Try this instead of Controls.Add(Place1):
>
>Me.FindControl("Form1").Controls.Add(Place1)
>
>(provided your form is called Form1, obviously, but that's what it's
>called by default).
>
>You were adding the radiobuttons in the Page controls, but outside of
>the Form controls.
>
>Also note that "Me." is only here for demonstration purposes. You can
>omit it, it's implicit.
>
>HTH,
>
>Michel
>
>Tom wilson <ye*******@nospam.com> wrote in messagenews:<57********************************@4ax.com> ... >> I'm trying to create dynamic controls in ASP.Net. It's driving me
>> nuts. I keep getting the error:
>>
>> Control '16' of type 'RadioButton' must be placed inside a form tag
>> with runat=server.
>>
>> Dim Place1 As New PlaceHolder
>> Controls.Add(Place1)
>> For y = 1 To Choices.RecordCount
>> Choices.MoveTo(y)
>> Dim Radio As New RadioButton
>> Radio.ID = choices.ID
>> Radio.Text = choices.ChoiceText
>> Radio.GroupName = Q.ID
>> Place1.Controls.Add(Radio)
>>
>> If I do Controls.Add(Radio) I get the above error. So I created a
>> placeholder in design view (there's nothing there since all page
>> content is dynamic). It added the radios but at the bottom of the
>> form. So I modified the code to dynamically create the placeholder
>> (as above). I STILL get this error.
>>
>> Do I have to do a:
>> response.write("<FORM etc etc... runat=server>")
>> before every checbox creation?
>>
>> Why doesn't it add the tags itself while its creating the controls?
>>
>> How do I add a control without getting that needless error at every
>> turn?
>>
>> Thanks!


Nov 19 '05 #5
1 - look at the aspx side of the page.

You will see the form element.

<form runat="server" id="myForm">

You can get this control by typing
Form = Page.FindControl( "myForm" );

Notice the parameter to FindControl is the ID of the control. If ID isn't
there, then assign it one.

ASP.NET is a completely different way of html generation. You really can't
think of things such as, "in asp I would just do document.write, etc." You
must think of terms of controls.

I really don't know enough about your requirements to tell you how and what
you should be doing, but I wish you the best of luck. There are several
ways to accomplish what you are trying to do.

Is the entire page dynamic? What determines the content? How much state
information should be maintained.

bill

You can always access the Request.Forms("txtName") and get the posted values
without worry about setting up control trees.
Also, if you really like the asp rendering module, you can always override
the Page.Render method and write out the html using Response.Write.
Although I don't think anyone on this board would recommend that approach.


"Tom wilson" <ye*******@nospam.com> wrote in message
news:0c********************************@4ax.com...
1 - How do I find that out? The Class is called "TestForm". It
appears to inherit from "MyApp.TestForm". Is that what I need?
Not complicated? This is a re-write of a survey application
originally done in asp. For that method, it was as simple as one line
of HTML to create a textbox and response.write the text/html. With
this I have to:

1 - Manually add a placeholder to the empty form. I can't create one
dynamically, everyt method I've tried fails.

2 - Create a set of control arrays for each type of control; checkbox,
radio, etc.

3 - Redim Preserve each array as the number of controls increases as
they are created. I hope 500 radios don't eat too much memory.

4 - Create the control, takes about 5 lines of code not including the
array tracking.

5 - Add the newly created control to the placeholder.

...and everything must be a control. Text? HTML? They have to be
defined as LiteralControl(s) and added in sequence. I remember when
it was called "response.write" but if I do that, all the text is at
the top of the page and the controls underneath because response.write
doesn't add to a placeholder. I swear if I have to do tables my head
will explode.

Yes, it's that complicated.

Sorry about the rant, it's been 3 days at this with little progress.
I do very much appreciate your input.


On Wed, 9 Feb 2005 10:19:48 -0600, "William F. Robertson, Jr."
<th****@nameht.org> wrote:
Couple things.

1. What is your page derived from to have a FindForm method?
2. Your form is probably called frmTestForm.

me.FindControl( "frmTestForm" ).Controls.Add( Place1 )

It really isn't that complicated; it is simply a matter of learning the
framework. Although I do wish MS would have exposed the internal Form
property they have. Perhaps this will be modified in 2.0.

bill

"Tom wilson" <ye*******@nospam.com> wrote in message
news:er********************************@4ax.com.. .
When I add that line I get "Object reference not set to..." I've
tried it on its own page with nothing else but this:

Dim Place1 as new Placeholder
me.FindForm("TestForm").Controls.Add(Place1)

Same result. I have discovered that I can add a placeholder in design
view and it will accept control additions. I guess the whole problem
is that I cannot create a placeholder dynamically within the form
tags. I don't know why something so simple has to be so complicated.

On 8 Feb 2005 23:56:10 -0800, fd******@hotmail.com (fd123456) wrote:

>Hi Tom,
>
>Try this instead of Controls.Add(Place1):
>
>Me.FindControl("Form1").Controls.Add(Place1)
>
>(provided your form is called Form1, obviously, but that's what it's
>called by default).
>
>You were adding the radiobuttons in the Page controls, but outside of
>the Form controls.
>
>Also note that "Me." is only here for demonstration purposes. You can
>omit it, it's implicit.
>
>HTH,
>
>Michel
>
>Tom wilson <ye*******@nospam.com> wrote in message

news:<57********************************@4ax.com> ...
>> I'm trying to create dynamic controls in ASP.Net. It's driving me
>> nuts. I keep getting the error:
>>
>> Control '16' of type 'RadioButton' must be placed inside a form tag
>> with runat=server.
>>
>> Dim Place1 As New PlaceHolder
>> Controls.Add(Place1)
>> For y = 1 To Choices.RecordCount
>> Choices.MoveTo(y)
>> Dim Radio As New RadioButton
>> Radio.ID = choices.ID
>> Radio.Text = choices.ChoiceText
>> Radio.GroupName = Q.ID
>> Place1.Controls.Add(Radio)
>>
>> If I do Controls.Add(Radio) I get the above error. So I created a
>> placeholder in design view (there's nothing there since all page
>> content is dynamic). It added the radios but at the bottom of the
>> form. So I modified the code to dynamically create the placeholder
>> (as above). I STILL get this error.
>>
>> Do I have to do a:
>> response.write("<FORM etc etc... runat=server>")
>> before every checbox creation?
>>
>> Why doesn't it add the tags itself while its creating the controls?
>>
>> How do I add a control without getting that needless error at every
>> turn?
>>
>> Thanks!

Nov 19 '05 #6
Ok, I have the page working using a single static placeholder.
That'll do the job. 100% of the content is retrieved from a SQL
Server database and everything down to the text is generated
dynamcially. I'm just fighting with the session object now. :)

I appreciate your help. Thanks!
On Wed, 9 Feb 2005 13:50:16 -0600, "William F. Robertson, Jr."
<th****@nameht.org> wrote:
1 - look at the aspx side of the page.

You will see the form element.

<form runat="server" id="myForm">

You can get this control by typing
Form = Page.FindControl( "myForm" );

Notice the parameter to FindControl is the ID of the control. If ID isn't
there, then assign it one.

ASP.NET is a completely different way of html generation. You really can't
think of things such as, "in asp I would just do document.write, etc." You
must think of terms of controls.

I really don't know enough about your requirements to tell you how and what
you should be doing, but I wish you the best of luck. There are several
ways to accomplish what you are trying to do.

Is the entire page dynamic? What determines the content? How much state
information should be maintained.

bill

You can always access the Request.Forms("txtName") and get the posted values
without worry about setting up control trees.
Also, if you really like the asp rendering module, you can always override
the Page.Render method and write out the html using Response.Write.
Although I don't think anyone on this board would recommend that approach.


"Tom wilson" <ye*******@nospam.com> wrote in message
news:0c********************************@4ax.com.. .
1 - How do I find that out? The Class is called "TestForm". It
appears to inherit from "MyApp.TestForm". Is that what I need?
Not complicated? This is a re-write of a survey application
originally done in asp. For that method, it was as simple as one line
of HTML to create a textbox and response.write the text/html. With
this I have to:

1 - Manually add a placeholder to the empty form. I can't create one
dynamically, everyt method I've tried fails.

2 - Create a set of control arrays for each type of control; checkbox,
radio, etc.

3 - Redim Preserve each array as the number of controls increases as
they are created. I hope 500 radios don't eat too much memory.

4 - Create the control, takes about 5 lines of code not including the
array tracking.

5 - Add the newly created control to the placeholder.

...and everything must be a control. Text? HTML? They have to be
defined as LiteralControl(s) and added in sequence. I remember when
it was called "response.write" but if I do that, all the text is at
the top of the page and the controls underneath because response.write
doesn't add to a placeholder. I swear if I have to do tables my head
will explode.

Yes, it's that complicated.

Sorry about the rant, it's been 3 days at this with little progress.
I do very much appreciate your input.


On Wed, 9 Feb 2005 10:19:48 -0600, "William F. Robertson, Jr."
<th****@nameht.org> wrote:
>Couple things.
>
>1. What is your page derived from to have a FindForm method?
>2. Your form is probably called frmTestForm.
>
>me.FindControl( "frmTestForm" ).Controls.Add( Place1 )
>
>It really isn't that complicated; it is simply a matter of learning the
>framework. Although I do wish MS would have exposed the internal Form
>property they have. Perhaps this will be modified in 2.0.
>
>bill
>
>"Tom wilson" <ye*******@nospam.com> wrote in message
>news:er********************************@4ax.com.. .
>> When I add that line I get "Object reference not set to..." I've
>> tried it on its own page with nothing else but this:
>>
>> Dim Place1 as new Placeholder
>> me.FindForm("TestForm").Controls.Add(Place1)
>>
>> Same result. I have discovered that I can add a placeholder in design
>> view and it will accept control additions. I guess the whole problem
>> is that I cannot create a placeholder dynamically within the form
>> tags. I don't know why something so simple has to be so complicated.
>>
>>
>>
>> On 8 Feb 2005 23:56:10 -0800, fd******@hotmail.com (fd123456) wrote:
>>
>> >Hi Tom,
>> >
>> >Try this instead of Controls.Add(Place1):
>> >
>> >Me.FindControl("Form1").Controls.Add(Place1)
>> >
>> >(provided your form is called Form1, obviously, but that's what it's
>> >called by default).
>> >
>> >You were adding the radiobuttons in the Page controls, but outside of
>> >the Form controls.
>> >
>> >Also note that "Me." is only here for demonstration purposes. You can
>> >omit it, it's implicit.
>> >
>> >HTH,
>> >
>> >Michel
>> >
>> >Tom wilson <ye*******@nospam.com> wrote in message
>news:<57********************************@4ax.com> ...
>> >> I'm trying to create dynamic controls in ASP.Net. It's driving me
>> >> nuts. I keep getting the error:
>> >>
>> >> Control '16' of type 'RadioButton' must be placed inside a form tag
>> >> with runat=server.
>> >>
>> >> Dim Place1 As New PlaceHolder
>> >> Controls.Add(Place1)
>> >> For y = 1 To Choices.RecordCount
>> >> Choices.MoveTo(y)
>> >> Dim Radio As New RadioButton
>> >> Radio.ID = choices.ID
>> >> Radio.Text = choices.ChoiceText
>> >> Radio.GroupName = Q.ID
>> >> Place1.Controls.Add(Radio)
>> >>
>> >> If I do Controls.Add(Radio) I get the above error. So I created a
>> >> placeholder in design view (there's nothing there since all page
>> >> content is dynamic). It added the radios but at the bottom of the
>> >> form. So I modified the code to dynamically create the placeholder
>> >> (as above). I STILL get this error.
>> >>
>> >> Do I have to do a:
>> >> response.write("<FORM etc etc... runat=server>")
>> >> before every checbox creation?
>> >>
>> >> Why doesn't it add the tags itself while its creating the controls?
>> >>
>> >> How do I add a control without getting that needless error at every
>> >> turn?
>> >>
>> >> Thanks!
>>
>


Nov 19 '05 #7
Glad to here you got it "working'.

If you give up fighting the Session, post another entry and you will surely
be helped...

bill

"Tom wilson" <ye*******@nospam.com> wrote in message
news:lb********************************@4ax.com...
Ok, I have the page working using a single static placeholder.
That'll do the job. 100% of the content is retrieved from a SQL
Server database and everything down to the text is generated
dynamcially. I'm just fighting with the session object now. :)

I appreciate your help. Thanks!
On Wed, 9 Feb 2005 13:50:16 -0600, "William F. Robertson, Jr."
<th****@nameht.org> wrote:
1 - look at the aspx side of the page.

You will see the form element.

<form runat="server" id="myForm">

You can get this control by typing
Form = Page.FindControl( "myForm" );

Notice the parameter to FindControl is the ID of the control. If ID isn'tthere, then assign it one.

ASP.NET is a completely different way of html generation. You really can'tthink of things such as, "in asp I would just do document.write, etc." Youmust think of terms of controls.

I really don't know enough about your requirements to tell you how and whatyou should be doing, but I wish you the best of luck. There are several
ways to accomplish what you are trying to do.

Is the entire page dynamic? What determines the content? How much state
information should be maintained.

bill

You can always access the Request.Forms("txtName") and get the posted valueswithout worry about setting up control trees.
Also, if you really like the asp rendering module, you can always overridethe Page.Render method and write out the html using Response.Write.
Although I don't think anyone on this board would recommend that approach.

"Tom wilson" <ye*******@nospam.com> wrote in message
news:0c********************************@4ax.com.. .
1 - How do I find that out? The Class is called "TestForm". It
appears to inherit from "MyApp.TestForm". Is that what I need?
Not complicated? This is a re-write of a survey application
originally done in asp. For that method, it was as simple as one line
of HTML to create a textbox and response.write the text/html. With
this I have to:

1 - Manually add a placeholder to the empty form. I can't create one
dynamically, everyt method I've tried fails.

2 - Create a set of control arrays for each type of control; checkbox,
radio, etc.

3 - Redim Preserve each array as the number of controls increases as
they are created. I hope 500 radios don't eat too much memory.

4 - Create the control, takes about 5 lines of code not including the
array tracking.

5 - Add the newly created control to the placeholder.

...and everything must be a control. Text? HTML? They have to be
defined as LiteralControl(s) and added in sequence. I remember when
it was called "response.write" but if I do that, all the text is at
the top of the page and the controls underneath because response.write
doesn't add to a placeholder. I swear if I have to do tables my head
will explode.

Yes, it's that complicated.

Sorry about the rant, it's been 3 days at this with little progress.
I do very much appreciate your input.


On Wed, 9 Feb 2005 10:19:48 -0600, "William F. Robertson, Jr."
<th****@nameht.org> wrote:

>Couple things.
>
>1. What is your page derived from to have a FindForm method?
>2. Your form is probably called frmTestForm.
>
>me.FindControl( "frmTestForm" ).Controls.Add( Place1 )
>
>It really isn't that complicated; it is simply a matter of learning the >framework. Although I do wish MS would have exposed the internal Form
>property they have. Perhaps this will be modified in 2.0.
>
>bill
>
>"Tom wilson" <ye*******@nospam.com> wrote in message
>news:er********************************@4ax.com.. .
>> When I add that line I get "Object reference not set to..." I've
>> tried it on its own page with nothing else but this:
>>
>> Dim Place1 as new Placeholder
>> me.FindForm("TestForm").Controls.Add(Place1)
>>
>> Same result. I have discovered that I can add a placeholder in design >> view and it will accept control additions. I guess the whole problem >> is that I cannot create a placeholder dynamically within the form
>> tags. I don't know why something so simple has to be so complicated. >>
>>
>>
>> On 8 Feb 2005 23:56:10 -0800, fd******@hotmail.com (fd123456) wrote:
>>
>> >Hi Tom,
>> >
>> >Try this instead of Controls.Add(Place1):
>> >
>> >Me.FindControl("Form1").Controls.Add(Place1)
>> >
>> >(provided your form is called Form1, obviously, but that's what it's >> >called by default).
>> >
>> >You were adding the radiobuttons in the Page controls, but outside of >> >the Form controls.
>> >
>> >Also note that "Me." is only here for demonstration purposes. You can >> >omit it, it's implicit.
>> >
>> >HTH,
>> >
>> >Michel
>> >
>> >Tom wilson <ye*******@nospam.com> wrote in message
>news:<57********************************@4ax.com> ...
>> >> I'm trying to create dynamic controls in ASP.Net. It's driving me >> >> nuts. I keep getting the error:
>> >>
>> >> Control '16' of type 'RadioButton' must be placed inside a form tag >> >> with runat=server.
>> >>
>> >> Dim Place1 As New PlaceHolder
>> >> Controls.Add(Place1)
>> >> For y = 1 To Choices.RecordCount
>> >> Choices.MoveTo(y)
>> >> Dim Radio As New RadioButton
>> >> Radio.ID = choices.ID
>> >> Radio.Text = choices.ChoiceText
>> >> Radio.GroupName = Q.ID
>> >> Place1.Controls.Add(Radio)
>> >>
>> >> If I do Controls.Add(Radio) I get the above error. So I created a >> >> placeholder in design view (there's nothing there since all page
>> >> content is dynamic). It added the radios but at the bottom of the >> >> form. So I modified the code to dynamically create the placeholder >> >> (as above). I STILL get this error.
>> >>
>> >> Do I have to do a:
>> >> response.write("<FORM etc etc... runat=server>")
>> >> before every checbox creation?
>> >>
>> >> Why doesn't it add the tags itself while its creating the controls? >> >>
>> >> How do I add a control without getting that needless error at every >> >> turn?
>> >>
>> >> Thanks!
>>
>

Nov 19 '05 #8

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

Similar topics

1
by: John MacIntyre | last post by:
Hi, I am having a problem executing server side javascript. For some reason the script tag is ignored when the runat=server is combined with the src attribute. The code is being used client...
1
by: Gary Bagen | last post by:
Hello, I am working on a page transition scheme and was wondering what the quickest way is to find out which ASP.NET controls need to be inside a form with runat=server. I've determined that...
4
by: Matthew Louden | last post by:
It happend to me more than once. When I create web controls or move the positions in VS.NET, I encountered the following run-time errors: It doesn't matter what controls I create, the following...
9
by: Jay | last post by:
Where is there a good article/description on why everything is runat=server. I just can't seem to grasp why ALL tags (even table tags) are runat server in dotnet. Thank You
3
by: testemail | last post by:
Hello How do I perform a variable replacement in ASP.NET when I am using the runat=server clause to generate a table - it was simple in ASP With ASP : ---------- <HTML> .... <BODY>
1
by: Dave | last post by:
When I drop my custom control on my webform, I get "Error creating control..Unknown server tag 'cc1:MyGridView'" Here's the code, any suggestions would be appreciated. dave. <%@ Register...
0
by: davidr | last post by:
Hi, I have a panel that I load user Control in no problem. The problem arrises when I do a post back on one of these user controls. I have button it does a click event. In this click event I...
1
by: waihung.wee | last post by:
Hi I got the following error in my xxx.cs file (code behind file) According to the error message, I should add a form tag in the file. But form tag should not appear in a code behind file ...
2
by: André | last post by:
Hi, i get sometimes an very unexpected error: "A form tag with runat=server must exist on the Page to use SetFocus() or the Focus property" at line: If j = 1 Then txta(i).Focus() There is 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
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:
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.