473,785 Members | 2,482 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error on adding custom control using RenderControl()

3 New Member
Hi,
In my webpage, i am adding my user control using rendercontrol() using the following code:

Dim NumericEditCont rol As New Control
NumericEditCont rol = LoadControl("Co ntrols\NumericE dit.ascx")

Dim sb As New StringBuilder()
Dim sw As New StringWriter(sb )
Dim htw As New HtmlTextWriter( sw)

NumericEditCont rol.RenderContr ol(htw)
Panel.Controls. Add(ParseContro l(sb.ToString() ))


Control 'NumericEditTex tBox' of type 'TextBox' must be placed inside a form tag with runat=server

The user control will not have any form tag defined in it. The above code is defined in a web page.
Am I missing something? Any help on this is highly appreciable..
Jul 6 '07 #1
5 3187
kenobewan
4,871 Recognized Expert Specialist
That numericedittext box must be placed in a form is this the problem?
Jul 6 '07 #2
rajdevramasamy
3 New Member
That numericedittext box must be placed in a form is this the problem?
The numericedittext box is withing the user control and the usercontrol will not have any form tag defined in it.
Jul 6 '07 #3
dip_developer
648 Recognized Expert Contributor
Hi,
In my webpage, i am adding my user control using rendercontrol() using the following code:

Dim NumericEditCont rol As New Control
NumericEditCont rol = LoadControl("Co ntrols\NumericE dit.ascx")

Dim sb As New StringBuilder()
Dim sw As New StringWriter(sb )
Dim htw As New HtmlTextWriter( sw)

NumericEditCont rol.RenderContr ol(htw)
Panel.Controls. Add(ParseContro l(sb.ToString() ))

Control 'NumericEditTex tBox' of type 'TextBox' must be placed inside a form tag with runat=server

The user control will not have any form tag defined in it. The above code is defined in a web page.
Am I missing something? Any help on this is highly appreciable..
not sure but I have a doubt......whil e adding your control to panel you may try............ .
Expand|Select|Wrap|Line Numbers
  1.  Page.FindControl("Form1").FindControl("Panel").Controls.Add(ParseControl(sb.ToString()))
Jul 6 '07 #4
rajdevramasamy
3 New Member
not sure but I have a doubt......whil e adding your control to panel you may try............ .
Expand|Select|Wrap|Line Numbers
  1.  Page.FindControl("Form1").FindControl("Panel").Controls.Add(ParseControl(sb.ToString()))
I have tried that also, but the ParseControl is creating error.
Jul 6 '07 #5
dip_developer
648 Recognized Expert Contributor
I have tried that also, but the ParseControl is creating error.
then some R & D is needed.....lets think.....
Jul 6 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

16
7239
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
2
4773
by: Tom Bray | last post by:
Ok I am baffled I can not figure out this problem. I am getting the following error: Portal Error - A DropDownList cannot have multiple items selected. Error information Name Value Message A DropDownList cannot have multiple items selected. Source System.Web TargetSite Void RenderContents(System.Web.UI.HtmlTextWriter)
6
6126
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page then tried to access 2nd, or 3rd, etc page. The problem is it happens sometimes - sometimes when they clicked refresh button, then everything is ok. Now they told me it happens more frequently. but I have tried by myself many times and never got...
5
5141
by: Nathan Sokalski | last post by:
When running a page I am working on, I recieve the following error: Cannot use a leading .. to exit above the top directory. I suspect this has something to do with the problem I posted in a recent posting "HyperLink.NavigateUrl always adds an extra ../ when going to a higher level directory" on Sunday, May 29, 2005 7:33 PM However, I cannot be sure because I cannot view the generated code since it gives the error before anything is...
0
1921
by: Ross M | last post by:
Dear Microsoft, I m getting this error message, on every SECOND attempt to access a web service on a foreign PC. I am using .net framework 2 beta 2 with Visual Web developer 2. Below is the error and associated files: 1) The error report by the ASP.net engine.
2
1699
by: Pipo | last post by:
Nobody knows how to get the values provided in the client can be read in the user-control? If have made a Web Custom Control with 2 textboxes and 1 dropdownlist. The user fills in my control (the textboxes and the dropdownlist) and lots more stuff on the page. When the user wants to save the page he'll click the save button. The server gets the postback but I can read out the filled in controls (in my control). The textboxes text = ""...
7
6541
by: Jonas | last post by:
Hi. I'm trying to develop a web custom control that uses a programmatically created treeview. My problem is that I get an exception when I try to render the control. With properties do I have to assign to get this working. Here is some sample code: namespace WebControlLibrary1 {
3
1565
by: weboweb | last post by:
Hi, I'm new in web parts, I would like to understand a couple of things: Let's say I have a custom control that displays information. That info is fed to the control through an XML string, so the control parses it and builds itself. Now that XML is obtained in the parent page, by calling a c# dll that deals with the database tier. The page then populates some property in
0
2487
by: apenly | last post by:
Hi all- I'm trying to Render a TreeView in a custom control, but I'm receiving a NullReferenceException at runtime. If I put the TreeView on the page it works fine, but as soon as I try to render it within my control it crashes and burns. I've even tried placing it within another control (a PlaceHolder) and tried to render the PlaceHolder to no avail. Any ideas on how to fix this problem? Here's my code:
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10090
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9949
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.