Daspoo
Well-known member
Ok, Ive got a good question (I think..heh)... I am trying to dynamically add textboxes and labels to a webform at runtime, and so far the labels are working perfectly. The textboxes, however, do not work. When I run the project (VB/ASP.NET web App, BTW), I get the following error message:
=============================================
Server Error in /WebAppCrystalRevisit Application.
--------------------------------------------------------------------------------
Control txtParams2 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 txtParams2 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.
=============================================
Heres my code:
=============================================
How do I add this "runat=server" line item from within VB code? Any help would be greatly appreciated!! Thanks in advance!
[edit]Please use
=============================================
Server Error in /WebAppCrystalRevisit Application.
--------------------------------------------------------------------------------
Control txtParams2 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 txtParams2 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.
=============================================
Heres my code:
Code:
For j = 0 To thisOne.ParamCount - 1
Labels...
myLabel(j) = New Label()
myLabel(j).Text = Trim(StrConv(thisOne.ParamPrompt(j), VbStrConv.ProperCase))
myLabel(j).ID = "Label" & (j + 2).ToString
myLabel(j).Visible = True
Controls.Add(PlaceHolder1)
PlaceHolder1.Controls.Add(Panel1)
Panel1.Controls.Add(myLabel(j))
Textboxes...
txtParams(j) = New TextBox()
txtParams(j).ID = "txtParams" & (j + 2).ToString
Controls.Add(PlaceHolder1)
PlaceHolder1.Controls.Add(Panel1)
Panel1.Controls.Add(txtParams(j))
Add a spacer in the form of an HTML <p> element
Dim spacer As LiteralControl = New LiteralControl("<p>")
Panel1.Controls.Add(spacer)
Panel1.Controls.Add(spacer)
Panel1.Controls.Add(spacer)
Next
How do I add this "runat=server" line item from within VB code? Any help would be greatly appreciated!! Thanks in advance!
[edit]Please use
Code:
tags [/ vb][/COLOR] [/edit]
Last edited by a moderator: