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

Custom Composite control error

What is wrong with this code?
I get no errors on compilation of my assembly

But On compilation on my Webpage i keep getting this error
"Unable to find control id 'FreeBox1' referenced by the 'ControlToValidate'
property of ''"

public class FreeBox : TextBox{

private Label lblTitle = new Label();
private RequiredFieldValidator req ;

public string Title {
get { return lblTitle.Text; }
set { lblTitle.Text = value; }
}
public string ReturnValue {
get { return this.Text; }
set { this.Text = value; }
}

protected override void OnInit(EventArgs e) {
req = new RequiredFieldValidator();
req.ControlToValidate = this.ID;
req.ErrorMessage = "*";
Controls.Add(req);
}

protected override void Render(HtmlTextWriter writer) {
lblTitle.RenderControl(writer);
base.Render(writer);
req.RenderControl(writer);
}

}

original code from this tutorial
"http://www.codeproject.com/aspnet/textboxwithvalidator.asp"
Sep 4 '06 #1
1 1121
Hi,

benoit wrote:
What is wrong with this code?
I get no errors on compilation of my assembly

But On compilation on my Webpage i keep getting this error
"Unable to find control id 'FreeBox1' referenced by the 'ControlToValidate'
property of ''"
<snip>
req.ControlToValidate = this.ID;
<snip>

You should use ClientID instead of ID. The ID is the value set by the
developer in the ASPX code or in the code-behind for the control.
However, if you have more than one control on the same page, there is a
risk that the ID won't be unique. This is why the compiler "computes" a
unique ID, which can be accessed using ClientID. Typically, it will be
something like "parentId_myId", where "parentId" is the parent's ID, and
"myId" is the control's ID.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 4 '06 #2

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

Similar topics

5
by: Barry Carr | last post by:
Hi, I've created a composite custom web control and a ControlDesigner descendant to render the control a design time. The child controls are public properties of composite control and as such...
2
by: Crosta | last post by:
Hi everyone, As subject suggests I'm wondering how is it possible to do so in ASP.NET. The fact is that I'd like to "atomize" an entire series of custom user controls (.ascx and .ascx.vb) to...
3
by: Lisa Calla | last post by:
Hi, I've been struggling with this for a few days. I've seen bits and pieces (how to set up custom validation), but I can't seem to understand how to get client side validation for my custom...
1
by: BillGatesFan | last post by:
I have a custom composite control which was made from a textbox control on my ASPX page. Why when I find the control using Page.FindControl, it is coming up as a regular...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
0
by: James | last post by:
I have a composite custom control which is constructed of several other controls, such as command buttons, a listview etc. I have several controls which border the boundary of the container and have...
0
by: Pavan | last post by:
My name is Pavan and I am a software engineer working on ASP .Net web development. Currently I am using .Net 2.0 Professional Edition to develop my web pages. I have a problem
0
by: Ralph | last post by:
I have a web page that dynamically loads user controls based on user selection. I store these in an an array. One of the pages has a custom control on it. It is a composite control. I have a few...
2
by: Ron | last post by:
I would like some more information on custom controls, what they can do and things like that, what you would use them for etc... Can anyone here share some examples of what you have used a custom...
4
by: Rick | last post by:
Hello, I built a composite web control that has a textbox and a date control. added my custom control on a webform where there are other standard controls. Each control on the form has a...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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?

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.