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

Custom Validator doesn't work

Well,

I've tried to create a stupid custom validator to validate a checked checkbox.
Really simple, really stupid, but it's just for trying to do something better
than standard validator, that works great but has some limits.

Ok, this is what i've done (apart from the basic implementation that should
be done):

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);

if (RenderUplevel)
{
string script = "\r\n<script language=\"javascript\">\r\n" +
...............

to implement the script
and

protected override void AddAttributesToRender(HtmlTextWriter writer)
{
//writer.AddAttribute("controltovalidate", this.GetControlRenderID(ControlToValidate));
base.AddAttributesToRender(writer);

if (this.RenderUplevel)
{
String clientID = this.ClientID;

Page.ClientScript.RegisterExpandoAttribute(clientI D, "evaluationfunction",
"IsCheckBoxRequired");

...............

to add the javascript elements to the javascript code rendered by the framework.

I've tried both Firefox and IE, on XP PRO nor on a Windows 2003. In both
case IE seems to works, but in firefox doesn't.
At least the client-script doesn't fire.

Infact checking in the source code the

ctl00_MainContent_Control.evaluationfunction = "JavascriptFunctionName";

isn't there despite the RegisterExpandoAttribute set it correctly. Using
the writer.AddAttribute() in the AddAttributeToRender doesn't work either.

I really don't know.

I'm exausted and upset. I wasted half day to understand the reason ...

Any help?

Thanks Andrea


Mar 27 '06 #1
1 1825
Hello Andrea,

Have you considered Firefox being the problem?
Perhaps checking the firefox forum or actually mailing mozilla about it
will clarify.
I myself have noticed all kinds of small differences when comparing IE
and firefox.

another solution might be using a validationControl from asp.net 2.0
or you can always do something like if checkbox1.checked = true etc etc

Egu

Mar 27 '06 #2

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

Similar topics

2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
10
by: Rigs | last post by:
Hi, I have a textbox with a Custom Validator that utilizes the OnServerValidate method for that textbox. This works fine, however the method only executes when data exists in that textbox after...
5
by: Richard Payne | last post by:
Hi This is probably a newbie question but I can't seem to find a clear answer to the problem I have. I have created a Custom Validator control on my webform that works fine, but when I put...
9
by: Alex Shirley | last post by:
Hi there I’m simply trying to check for a blank or empty value in a textbox on my webform. In this instance I do not want to use a requiredfieldvalidator, I want to use a customvalidator (as I...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
1
by: Elie Medeiros via .NET 247 | last post by:
Hi there, I have written a custom validator function to validate a datefrom a user-filled field. The function tries to parse the dateand if it can't, sets (serverValidateEventArgs)e.IsValid...
5
by: Mattyw | last post by:
Hi, I'm relatively new to Web Forms, I have been using Required Field Validators and Regular Expression Validators on a Web Form I am developing and everything works as expected using Visual...
9
by: wardy1975 | last post by:
Hi All, Looking for a little expert advice on a few web standards issues. I am currently trying to understand the impact of web standards for a web application I work with. I have been doing a...
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...
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:
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...
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
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...

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.