T
Tony
Win XP - VS 2002 - VB - web forms
I'm creating a table, 2 labels, 1 text box dynamically (only show 1 of each
in code below)
I'm able to add the labels to the table at run time however I cannot add the
text boxes.
here is the code and then the error message,
Dim tblVD As New Table()
tblVD.Visible = True
tblVD.BackColor = Color.Ivory
tblVD.GridLines = GridLines.Both
Me.Controls.Add(tblVD)
Dim rforloop As Int16
Dim cforloop As Int16
For rforloop = 0 To 4
Dim trow As New TableRow()
For cforloop = 0 To 3
Dim tcell As New TableCell()
trow.Cells.Add(tcell)
Next cforloop
tblVD.Rows.Add(trow)
Next rforloop
Dim lab As New Label()
lab.Text = "lab"
tblVD.Rows(0).Cells(0).Controls.Add(lab)
Dim txt As New TextBox()
txt.BorderStyle = BorderStyle.Groove
txt.Text = "Enter Info Here"
tblVD.Rows(0).Cells(1).Controls.Add(txt)
tblVD.Style.Add("10", "Z-INDEX: 101; LEFT: 96px; POSITION: absolute; TOP:
96px")
---------------Error
Below-------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------
Control '_ctl2' 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 '_ctl2' of type
'TextBox' must be placed inside a form tag with runat=server.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Control '_ctl2' of type 'TextBox' must be
placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +151
System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter
writer) +40
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.WebControls.TableCell.RenderContents(HtmlTextWriter writer)
+55
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.WebControls.Table.RenderContents(HtmlTextWriter writer)
+102
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
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() +1926
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032
Thanks for any help
Tony
I'm creating a table, 2 labels, 1 text box dynamically (only show 1 of each
in code below)
I'm able to add the labels to the table at run time however I cannot add the
text boxes.
here is the code and then the error message,
Dim tblVD As New Table()
tblVD.Visible = True
tblVD.BackColor = Color.Ivory
tblVD.GridLines = GridLines.Both
Me.Controls.Add(tblVD)
Dim rforloop As Int16
Dim cforloop As Int16
For rforloop = 0 To 4
Dim trow As New TableRow()
For cforloop = 0 To 3
Dim tcell As New TableCell()
trow.Cells.Add(tcell)
Next cforloop
tblVD.Rows.Add(trow)
Next rforloop
Dim lab As New Label()
lab.Text = "lab"
tblVD.Rows(0).Cells(0).Controls.Add(lab)
Dim txt As New TextBox()
txt.BorderStyle = BorderStyle.Groove
txt.Text = "Enter Info Here"
tblVD.Rows(0).Cells(1).Controls.Add(txt)
tblVD.Style.Add("10", "Z-INDEX: 101; LEFT: 96px; POSITION: absolute; TOP:
96px")
---------------Error
Below-------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------
Control '_ctl2' 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 '_ctl2' of type
'TextBox' must be placed inside a form tag with runat=server.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Control '_ctl2' of type 'TextBox' must be
placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +151
System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter
writer) +40
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.WebControls.TableCell.RenderContents(HtmlTextWriter writer)
+55
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.WebControls.Table.RenderContents(HtmlTextWriter writer)
+102
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
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() +1926
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032
Thanks for any help
Tony