Custom Validator doesn't work

A

Andrea

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(clientID, "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
 
E

eguworks

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top