PC Review


Reply
Thread Tools Rate Thread

Create controls dynamically: Getting an error

 
 
=?Utf-8?B?UGF0cmljayBNYXJ0aQ==?=
Guest
Posts: n/a
 
      17th Feb 2005
Hi together
I wish to create an object at runtime in the web. I get many good tips for
how to
do before two days by using the same Subject. So I got also the following link
wich is showing exactly that what I want to do

http://www.codeproject.com/aspnet/retainingstate.asp

but, I got always an error
>>Das Steuerelement 'ControlID_0' des Typs 'TextBox' muss in einem Formtag mit runat=server positioniert werden.]


that means that the element 'ControlID_0' has to be positioned in a tag with
"runat=server".

Maybe my error is to understand that container


TextBox tx = new TextBox();
tx.ID = "ControlID_" + i.ToString();
//Add the Controls to the container of your choice
this.Controls.Add(tx);

Many thanks again if you know a further tip
Greetings Patrick Marti


PS:
I add this in an new Message bec. the other was two days before and will
maybe not be seen any more

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmFrb2IgQ2hyaXN0ZW5zZW4=?=
Guest
Posts: n/a
 
      17th Feb 2005
What you are trying to do is add the textbox to the Page. Instead you need
to add the controls to an existing control which has the runat="server"
attribute which might be a form as in the following example:

// This works if you have a form tag on your page with id="Form1" and
// runat="server"
protected HtmlForm Form1;

private void Page_Load(object sender, System.EventArgs e)
{
TextBox box = new TextBox();
box.ID = "Textbox_1";
Form1.Controls.Add(box);
} }

HTH, Jakob.

"Patrick Marti" wrote:

> Hi together
> I wish to create an object at runtime in the web. I get many good tips for
> how to
> do before two days by using the same Subject. So I got also the following link
> wich is showing exactly that what I want to do
>
> http://www.codeproject.com/aspnet/retainingstate.asp
>
> but, I got always an error
> >>Das Steuerelement 'ControlID_0' des Typs 'TextBox' muss in einem Formtag mit runat=server positioniert werden.]

>
> that means that the element 'ControlID_0' has to be positioned in a tag with
> "runat=server".
>
> Maybe my error is to understand that container
>
>
> TextBox tx = new TextBox();
> tx.ID = "ControlID_" + i.ToString();
> //Add the Controls to the container of your choice
> this.Controls.Add(tx);
>
> Many thanks again if you know a further tip
> Greetings Patrick Marti
>
>
> PS:
> I add this in an new Message bec. the other was two days before and will
> maybe not be seen any more
>

 
Reply With Quote
 
=?Utf-8?B?UGF0cmljayBNYXJ0aQ==?=
Guest
Posts: n/a
 
      17th Feb 2005
Yes, my first dynamically object is born!!!
Thanks a lot!
Greetings Patrick

"Jakob Christensen" wrote:

> What you are trying to do is add the textbox to the Page. Instead you need
> to add the controls to an existing control which has the runat="server"
> attribute which might be a form as in the following example:
>
> // This works if you have a form tag on your page with id="Form1" and
> // runat="server"
> protected HtmlForm Form1;
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> TextBox box = new TextBox();
> box.ID = "Textbox_1";
> Form1.Controls.Add(box);
> } }
>
> HTH, Jakob.
>
> "Patrick Marti" wrote:
>
> > Hi together
> > I wish to create an object at runtime in the web. I get many good tips for
> > how to
> > do before two days by using the same Subject. So I got also the following link
> > wich is showing exactly that what I want to do
> >
> > http://www.codeproject.com/aspnet/retainingstate.asp
> >
> > but, I got always an error
> > >>Das Steuerelement 'ControlID_0' des Typs 'TextBox' muss in einem Formtag mit runat=server positioniert werden.]

> >
> > that means that the element 'ControlID_0' has to be positioned in a tag with
> > "runat=server".
> >
> > Maybe my error is to understand that container
> >
> >
> > TextBox tx = new TextBox();
> > tx.ID = "ControlID_" + i.ToString();
> > //Add the Controls to the container of your choice
> > this.Controls.Add(tx);
> >
> > Many thanks again if you know a further tip
> > Greetings Patrick Marti
> >
> >
> > PS:
> > I add this in an new Message bec. the other was two days before and will
> > maybe not be seen any more
> >

 
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
Create controls dynamically macca Microsoft C# .NET 2 19th Oct 2005 08:19 PM
Create controls dynamically: Getting an error =?Utf-8?B?VmFyYWQ=?= Microsoft Dot NET 3 16th Feb 2005 12:58 AM
Create Controls dynamically Bjorgvin Sigurdsson Microsoft Access Getting Started 2 15th Jan 2004 09:21 PM
Dynamically create controls ? Steven Caliendo Microsoft ASP .NET 3 22nd Dec 2003 09:27 PM
Re: Create controls dynamically Tom Ogilvy Microsoft Excel Programming 0 24th Nov 2003 03:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:38 AM.