473,410 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Text Box Problem

Hello,

I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.

I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.

I have no idea why do I get this error.
The form with Runat="server" is in the master page.

Anyway, can someone tell me how can I figure what is going on?

Thanks,
Miguel

Nov 8 '06 #1
2 1467
Here is my code.

I am adding and creating all controls at runtime in my pages.

------------------------------------------------------------------------

Base.master:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server"></form>
</body>
</html>

Base.master.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init

Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)

Dim cphContent As New ContentPlaceHolder
AddHandler cphContent.Init, AddressOf cphContent_Init
pContent.Controls.Add(cphContent)

End Sub

MyPage.aspx:

<%@ Page Language="VB" CodeFile="Default.aspx.vb" Inherits="_Default"
%>
MyPage.aspx.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init

Dim by27fContactForm As New By27.Web.UI.Form.Contact
AddHandler by27fContactForm.Init, AddressOf by27fContactForm_Init
pContacts.Controls.Add(by27fContactForm)

End Sub

Class Contact in Namespace By27.Web.UI:

Namespace Web.UI.Form

' Content
<DefaultProperty("Text"), ToolboxData("<{0}:ContactForm
runat=server></{0}:ContactForm>")_
Public Class Contact
Inherits WebControl

Dim by27cf_tbName As New WebControls.TextBox
Private Sub by27cf_tbName_Init(ByVal sender As Object, ByVal e As
System.EventArgs)
With by27cf_tbName
.CssClass = Me.TextBoxCssClass
.ID = "by27cf_tbName"
.Width = Unit.Percentage(100)
End With
End Sub

<Bindable(True), Category("Appearance"), DefaultValue(""),
Localizable(True)Property TextBoxCssClass() As String
Get
If CStr(ViewState("TextBoxCssClass")) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState("TextBoxCssClass"))
End If
End Get
Set(ByVal Value As String)
ViewState("TextBoxCssClass") = Value
End Set
End Property

Protected Overrides Sub CreateChildControls()
AddHandler by27cf_tbName.Init, AddressOf by27cf_tbName_Init
MyBase.Controls.Add(by27cf_tbName)
' Create child controls
MyBase.CreateChildControls()
Me.ChildControlsCreated = True
End Sub

End Class

------------------------------------------------------------------------

Thanks,

Miguel

shapper wrote:
Hello,

I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.

I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.

I have no idea why do I get this error.
The form with Runat="server" is in the master page.

Anyway, can someone tell me how can I figure what is going on?

Thanks,
Miguel
Nov 8 '06 #2
This is a bug of Visual Studio. A problem is that in content page you don't
have form
"shapper" <md*****@gmail.comwrote in message
news:11*********************@m7g2000cwm.googlegrou ps.com...
Hello,

I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.

I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.

I have no idea why do I get this error.
The form with Runat="server" is in the master page.

Anyway, can someone tell me how can I figure what is going on?

Thanks,
Miguel


Nov 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jiwei06xie | last post by:
Hi All, I am trying to upgrade an Access 2000 DB to 2007 (using linked tables and ODBC to connect to backend SQL 2000 database). In my DB, I have a mainswitch board and some command buttons on it....
7
by: poornesh K V | last post by:
This is the details: I have a Form : ProjectDetails This form is made up of a TabControl : maintabctrl1 (Say 10 pages) Each page has a subform : subForm1 This subForm1 has tabcontrol :...
2
by: ratsat | last post by:
I have a database with over 100,000 records and the dates are all stored as text fields 01-JAN-1999. I need to convert them to a date field and have tried numerous options on my own and in examples...
0
by: teddarr | last post by:
I have a Windows Server 2003. I am trying to run multiple websites on the server. I am using host headers to run the websites on only one ip address. Before anyone says this is an iis issue and...
7
by: dawn123 | last post by:
I have a text box that I only want a user to be able to enter integers. I have it so that if a number with a decmail place is enter a error message comes up. But when i was testing the code, I...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.