Problems with Prado’s client side onclick event of a TLinkButton

Some time ago  I expirienced a strange and difficult to solve problem using the Prado framework. For those that are not aware this is a PHP framework which is ASP.NET alike – it simulates the workflow process of

So here is the problem: I had a long form full of controls and validators, but for one of the fields I needed to make  a javascript call to the confirm function. The reason was that we needed to ask the user if he/she wants to go ahead and leave a field blank or no. Ok that is fine but when having other fields and validators for them the confirm function should be called after all of them are validated ok on the client side. The onclick javascript event is called before the validation. That’s the problem. How did I solve it? Well  don’t like the solution but it seems to be the only one that I could figure out. Here it is:

  • I put this on the top of tha page as javascript code:

var hasError = false;

function emailCheckValidator(sender, parameter)
  if(!hasError && $('<%= $this->Email->ClientID %>').getValue().toString().length==0 && !confirm('<%=LABEL_SURE_CONTINUE%>'))
    return false;
    return true;
  • On each validator I set up a client side validation error like this:

  hasError = true;
  • Just before the link button I put the following:

  Style="display: none;" />
  FocusOnError="true" />
  • On the TLinkButton added the onclick client cide event:
  Attributes.OnClick="hasError = false;" />
  • And the last step set up the php custom validator function that is always returning true:
public function validateControlField($sender, $param)
  $param->IsValid = true;

That’s it. Prado is one very good framework. But I hate when i must write stuff like this. Have you a beter way to do it? Share it, please!

This post is also available in: Bulgarian

  1. I deceit delay to arrest that have been added from you . This is a rich blog absolutely .

  2. Achieve this product support a lot of actual to me! Recognizing the information absolutely , I will admit you .

  3. I saved your site that arrest here , a category rich acute everywhere !

  4. As news of this Court’s order broke last week, state and local officials publicly declared their intent to use the proposed operating system to open hundreds of other seized devices—in cases having nothing to do with terrorism.

  1. No trackbacks yet.