Custom Validator doesn't work

Discussion in 'ASP .Net' started by Andrea, Mar 27, 2006.

  1. Andrea

    Andrea Guest

    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
     
    Andrea, Mar 27, 2006
    #1
    1. Advertising

  2. Andrea

    Guest

    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, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mad Scientist Jr

    Validator doesn't work if autopostback=true

    Mad Scientist Jr, Jun 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    555
    Mad Scientist Jr
    Jun 18, 2004
  2. msa
    Replies:
    0
    Views:
    2,333
  3. Radu
    Replies:
    8
    Views:
    429
  4. Scott Yenor

    How to get custom control to work with custom validator

    Scott Yenor, Jan 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    236
    Scott Yenor
    Jan 27, 2004
  5. Sally
    Replies:
    2
    Views:
    213
    Sally
    Oct 19, 2005
Loading...

Share This Page