Home All Groups Group Topic Archive Search About
Author
10 May 2005 3:43 PM
mugurel
Trying to implement an composite control,  I OverRide CreateChildControls(),
where I  add my controls, dinamicaly. I try to ad an
System.Web.UI.WebControls.LinkButton Control, and I have the following ,
error :

Control '_ctl0' of type 'LinkButton' must be placed inside a form tag with
runat=server.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.


Exception Details: System.Web.HttpException: Control '_ctl0' of type
'LinkButton' must be placed inside a form tag with runat=server.

Source Error:


Line 52:             this.Attributes.Add("onmouseover","(window.status=\'" +
this.ToolTip.Replace("'","\'").Replace("\"","\\\"") + "\'); return true");
Line 53:             this.Attributes.Add("onmouseout","(window.status=\'\'); return
true");
Line 54:             base.Render(writer);
Line 55:         }
Line 56:     }

Stack Trace:


[HttpException (0x80004005): Control '_ctl0' of type 'LinkButton' must be
placed inside a form tag with runat=server.]
   System.Web.UI.Page.VerifyRenderingInServerForm(Control control)
   System.Web.UI.WebControls.LinkButton.AddAttributesToRender(HtmlTextWriter
writer)
   System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   WebControlLibrary.LinkButton.Render(HtmlTextWriter writer) in
C:\Inetpub\wwwroot\CALLCAPTURE\CallCapture.root\CallCapture\WebControlLibrary\LinkButton.cs:54
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   System.Web.UI.Control.Render(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   ASP.WebForm2_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer) in c:\inetpub\wwwroot\CallCapture\WebForm2.aspx:11
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   System.Web.UI.Control.Render(HtmlTextWriter writer)
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   System.Web.UI.Page.ProcessRequestMain()


It is necesary to set runat attribute to "server", for all controls created
dinamicaly ?

Author
10 May 2005 4:05 PM
Brock Allen
I suspect your Composite Contorl isn't inside page's <form runat=server>
tag. You can have controls outside the <form runat=server> but they can't
be the kinds of controls that induce a postback, such as a LinkButton.

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> Trying to implement an composite control,  I OverRide
> CreateChildControls(), where I  add my controls, dinamicaly. I try to
> ad an System.Web.UI.WebControls.LinkButton Control, and I have the
> following , error :
>
> Control '_ctl0' of type 'LinkButton' must be placed inside a form tag
> with runat=server. Description: An unhandled exception occurred during
> the execution of the current web request. Please review the stack
> trace for more information about the error and where it originated in
> the code.
>
> Exception Details: System.Web.HttpException: Control '_ctl0' of type
> 'LinkButton' must be placed inside a form tag with runat=server.
>
> Source Error:
>
> Line 52:             this.Attributes.Add("onmouseover","(window.status=\'" +
> this.ToolTip.Replace("'","\'").Replace("\"","\\\"") + "\'); return
> true");
> Line 53:             this.Attributes.Add("onmouseout","(window.status=\'\');
> return
> true");
> Line 54:             base.Render(writer);
> Line 55:         }
> Line 56:     }
> Stack Trace:
>
> [HttpException (0x80004005): Control '_ctl0' of type 'LinkButton' must
> be
> placed inside a form tag with runat=server.]
> System.Web.UI.Page.VerifyRenderingInServerForm(Control control)
>
> System.Web.UI.WebControls.LinkButton.AddAttributesToRender(HtmlTextWri
> ter
> writer)
> System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter
> writer)
> System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
> WebControlLibrary.LinkButton.Render(HtmlTextWriter writer) in
> C:\Inetpub\wwwroot\CALLCAPTURE\CallCapture.root\CallCapture\WebControl
> Library\LinkButton.cs:54
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
> System.Web.UI.Control.Render(HtmlTextWriter writer)
> System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
> writer)
> System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> ASP.WebForm2_aspx.__Render__control1(HtmlTextWriter __output,
> Control
> parameterContainer) in c:\inetpub\wwwroot\CallCapture\WebForm2.aspx:11
> System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
> System.Web.UI.Control.Render(HtmlTextWriter writer)
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> System.Web.UI.Page.ProcessRequestMain()
> It is necesary to set runat attribute to "server", for all controls
> created dinamicaly ?
>
Author
10 May 2005 4:29 PM
mugurel
No the control is inside of form.
Here you have CreateChildControls function:

        protected override void CreateChildControls()
        {
            bool last = false;
            for(int i = 0; i < text.Count; i++)
            {
                last = (i == text.Count - 1);

                if(last)
                {
                    Label lb = new Label();
                    lb.Text = HttpUtility.HtmlEncode(text[i]);
                    Controls.Add(lb);
                }
                else
                {
                    LinkButton lk = new LinkButton();
                    lk.Text = text[i];
                    Controls.Add(lk);

                    lk.Click += new EventHandler(lk_Click);

                    Label lb = new Label();
                    lb.Text = ">";
                    Controls.Add(lb);
                }
            }
        }


Show quoteHide quote
"Brock Allen" wrote:

> I suspect your Composite Contorl isn't inside page's <form runat=server>
> tag. You can have controls outside the <form runat=server> but they can't
> be the kinds of controls that induce a postback, such as a LinkButton.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > Trying to implement an composite control,  I OverRide
> > CreateChildControls(), where I  add my controls, dinamicaly. I try to
> > ad an System.Web.UI.WebControls.LinkButton Control, and I have the
> > following , error :
> >
> > Control '_ctl0' of type 'LinkButton' must be placed inside a form tag
> > with runat=server. Description: An unhandled exception occurred during
> > the execution of the current web request. Please review the stack
> > trace for more information about the error and where it originated in
> > the code.
> >
> > Exception Details: System.Web.HttpException: Control '_ctl0' of type
> > 'LinkButton' must be placed inside a form tag with runat=server.
> >
> > Source Error:
> >
> > Line 52:             this.Attributes.Add("onmouseover","(window.status=\'" +
> > this.ToolTip.Replace("'","\'").Replace("\"","\\\"") + "\'); return
> > true");
> > Line 53:             this.Attributes.Add("onmouseout","(window.status=\'\');
> > return
> > true");
> > Line 54:             base.Render(writer);
> > Line 55:         }
> > Line 56:     }
> > Stack Trace:
> >
> > [HttpException (0x80004005): Control '_ctl0' of type 'LinkButton' must
> > be
> > placed inside a form tag with runat=server.]
> > System.Web.UI.Page.VerifyRenderingInServerForm(Control control)
> >
> > System.Web.UI.WebControls.LinkButton.AddAttributesToRender(HtmlTextWri
> > ter
> > writer)
> > System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter
> > writer)
> > System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
> > WebControlLibrary.LinkButton.Render(HtmlTextWriter writer) in
> > C:\Inetpub\wwwroot\CALLCAPTURE\CallCapture.root\CallCapture\WebControl
> > Library\LinkButton.cs:54
> > System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> > System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
> > System.Web.UI.Control.Render(HtmlTextWriter writer)
> > System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
> > writer)
> > System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
> > System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> > ASP.WebForm2_aspx.__Render__control1(HtmlTextWriter __output,
> > Control
> > parameterContainer) in c:\inetpub\wwwroot\CallCapture\WebForm2.aspx:11
> > System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
> > System.Web.UI.Control.Render(HtmlTextWriter writer)
> > System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> > System.Web.UI.Page.ProcessRequestMain()
> > It is necesary to set runat attribute to "server", for all controls
> > created dinamicaly ?
> >
>
>
>
>
Author
10 May 2005 4:41 PM
Brock Allen
> No the control is inside of form.

Do you mean page or server side form? If your Custom Control is really inside
the <form runat=server> tag in the page then I don't know what the error
"Control '_ctl0' of type 'LinkButton' must be placed inside a form tag with
runat=server" means. Sorry.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Author
10 May 2005 4:51 PM
mugurel
In fact the problem was <form> tag.
thank you Allen.

Show quoteHide quote
"Brock Allen" wrote:

> > No the control is inside of form.
>
> Do you mean page or server side form? If your Custom Control is really inside
> the <form runat=server> tag in the page then I don't know what the error
> "Control '_ctl0' of type 'LinkButton' must be placed inside a form tag with
> runat=server" means. Sorry.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>