473,378 Members | 1,470 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,378 software developers and data experts.

Composite WebControl validator problem

Hello,

I am creating a framework of custom webcontrols, for example, a
combined textbox and validator. I need to be able to add the validator
dynamically.

My problem is that the validator doesn't react when my form is
submitted.

The code below is a simple example that reproduces the behaviour.
Without implementing INamingContainer, it works fine, but then I lose
viewstate for the child controls.

I will appreciate any help a lot!
CustomControl.cs
-----------------------------------------------
public class CustomControl : WebControl, INamingContainer
{
protected override void CreateChildControls()
{
//
TextBox t = new TextBox();
t.ID = "t";

Controls.Add(t);

//
RequiredFieldValidator r = new RequiredFieldValidator();
r.ErrorMessage = "Error Message";
r.ControlToValidate = "t";

Controls.Add(r);

//
Button b = new Button();
b.Text = "Validate";

Controls.Add(b);
}
}
Default.aspx
-----------------------------------------------
....
<html>
...
<form runat="server">
<namespace:CustomControl runat="server" id="id" />
</form>
...
</html>

Jun 1 '06 #1
0 835

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

Similar topics

1
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
2
by: Harry | last post by:
Hello, I have a composite WebControl that I'm dynamically instantiating at runtime using Reflection. When I create a new instance of my control I immediately iterate through it's child control...
2
by: Mark Goldin | last post by:
I am trying to create my first composite control. Here is the code: using System; using System.Collections; using System.ComponentModel;
3
by: Martin | last post by:
Hi, I have created a composite control that has a number of standard asp.net controls on it that can themselves cause postbacks. What i need to do in my composite control is to determine which...
1
by: Sam | last post by:
Hi all, Why can't i create a validatorControl as a child of the control to validate? It doesn't give any errors, but it just won't work (it's not validating). The reason why i want this is...
0
by: Peter Morris [Droopy eyes software] | last post by:
Hi all I need to create a composite control. This control should allow the site designer to add one or more "MyButton" instances to the list, they will then set various properties on the...
1
by: drop | last post by:
Hi, I'm using a Composite Date Control that I want to be able to validate Client-Side with the ASP RegularExpression Validator. I want the validator to be outside of the Composite Control so I...
6
by: shapper | last post by:
Hello, I am working in a class library with various custom controls. In which cases should a control inherit Control, WebControl and CompositeControl classes? And when should a custom...
0
by: blabello | last post by:
Good morning, I've been tasked to create a series of self-validating composite controls using standard Visual Studio/AJAX controls and some custom-made validation controls. One of them is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.