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

possible to create a control that adds portions of itself different places?

I have just created a custom control. it consists of a radiobuttonlist, and
a validator for that radiobuttonlist. I've added a property in my control
that holds a placeholder. I want to use this placeholder, so that I can add
the validator of my control somewhere else in the page than "inside" my
custom control.
By design it would be like this:

<someplaceholder>[Here goes the validator]</someplaceholder>
<myControl>[Here goes the radioButtonlist]</myControl>
What happens, is that I get this error:
"Control '_ctl0' referenced by the ControlToValidate property of
'ctrlReqFieldBool' cannot be validated."

Seems kinda strange to me, as I have no problem adding other things to my
"validatorPlacement" referenced control:
validatorPlacement.Controls.Add(new TextBox());
works just fine

In the .net reference, this is what I found about the validator:
"The ID must refer to a control within the same container as the validation
control. It must be in the same page or user control, or it must be in the
same template of a templated control."
I'm not sure if this means that I can't do what I'm trying to.

Here is some of my code:
--------------------------------------------------------------------------
public class
quizAns_Boolean:System.Web.UI.WebControls.WebContr ol,INamingContainer
{

private PlaceHolder ctrlControl;
public PlaceHolder validatorPlacement
{
get{return ctrlControl;}
set{ctrlControl=value;}
}
protected override void CreateChildControls()
{
//the radiobuttonlist
RadioButtonList ctrlAnsBool=new RadioButtonList();
ctrlAnsBool.ID=this.ID;
foreach(DataRow dr in ctrlDataSource)
{
ctrlAnsBool.Items.Add(new
ListItem(dr["answer"].ToString(),dr["answerID"].ToString()));
}
this.Controls.Add(ctrlAnsBool);

//the validator
RequiredFieldValidator ctrlReqFieldBool=new RequiredFieldValidator();
ctrlReqFieldBool.ID="ctrlReqFieldBool";
ctrlReqFieldBool.ControlToValidate=ctrlAnsBool.ID;
ctrlReqFieldBool.Display=ValidatorDisplay.Static;
ctrlReqFieldBool.Text="Required Answer";
ctrlReqFieldBool.ErrorMessage="Error";

//this one works just fine
validatorPlacement.Controls.Add(new TextBox());

//add the validator somewhere else, gives me an error
validatorPlacement.Controls.Add(ctrlReqFieldBool);


}
}
Nov 17 '05 #1
0 1091

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

Similar topics

1
by: pontifikas | last post by:
How difficult is it to have a project which contains portions of, say, C# and C++(or VB)? Can this be done? What are the general rules for doing such thing? *-----------------------* Posted at:...
1
by: Grey | last post by:
is it possible to dynamic create control in runtime. I want to create a new textbox on every click on the button.
0
by: Eric | last post by:
Hi I want to know if it's possible to create a control at runtime in a different process than the main form There is a fonction I try but I have a message that tell me I can create control on...
2
by: Tom | last post by:
Dear All : How to create control array class in vb.net and how to use loop method so that add all button of cuurent form into collection class Thanks
3
by: m | last post by:
Hi, I'm running MySQL (5.0.18-nt) on WinXP with latest patches. I've some SQL code that generates an 'ERROR 11' in two different places depending on how the code is submitted. At the moment...
2
by: jain_tj | last post by:
Could anyone please help me with the following problem My xml file is ============== <fig id="F0000001"> <caption>Caption text</caption> <image id="I0000001" image.class="halftone"...
2
by: gyanendar | last post by:
Hi I want to create control(txtbox,label..etc) in asp page in run time.Here I have a table in database where control name &type is give.I want to fetch control information from database and than...
2
by: Roobmeister | last post by:
Hi, I am new to Oracle, and can't find the answer for this anywhere. I have a giant SELECT query for a data extract that includes many subqueries. I would like to limit the data being queried...
2
by: Patrick McGilla | last post by:
I would like to use different link colors at different places on the same web page. Using CSS, I can't seem to differentiateand even tried using div statements to separate. Anyone got an idea? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.