D
David
I try to use the following code to add a textbox
dynamically in a web form in the a .aspx.vb file:
Private Sub updateButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
updateButton.Click
Dim TextBox2 As New TextBox()
Controls.Add(TextBox2)
however, I got the error message like following when I
click the button updateButton:
Server Error in '/WebApplication1' Application.
-----------------------------------------------------------
---------------------
Control '_ctl0' of type 'TextBox' 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 'TextBox' must be placed inside a
form tag with runat=server.
Stack Trace:
[HttpException (0x80004005): Control '_ctl0' of
type 'TextBox' must be placed inside a form tag with
runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control
control) +152
System.Web.UI.WebControls.TextBox.AddAttributesToRender
(HtmlTextWriter writer) +38
System.Web.UI.WebControls.WebControl.RenderBeginTag
(HtmlTextWriter writer) +17
System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter
writer) +17
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter
writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer) +243
System.Web.UI.Page.ProcessRequestMain() +1900
please help me to solve the problem.
thank you!
David
dynamically in a web form in the a .aspx.vb file:
Private Sub updateButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
updateButton.Click
Dim TextBox2 As New TextBox()
Controls.Add(TextBox2)
however, I got the error message like following when I
click the button updateButton:
Server Error in '/WebApplication1' Application.
-----------------------------------------------------------
---------------------
Control '_ctl0' of type 'TextBox' 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 'TextBox' must be placed inside a
form tag with runat=server.
Stack Trace:
[HttpException (0x80004005): Control '_ctl0' of
type 'TextBox' must be placed inside a form tag with
runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control
control) +152
System.Web.UI.WebControls.TextBox.AddAttributesToRender
(HtmlTextWriter writer) +38
System.Web.UI.WebControls.WebControl.RenderBeginTag
(HtmlTextWriter writer) +17
System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter
writer) +17
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter
writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer) +243
System.Web.UI.Page.ProcessRequestMain() +1900
please help me to solve the problem.
thank you!
David