Two Clicks Required

Sometimes, when I have an UpdatePanel and multiple validators on a page, I have to click twice on a LinkButton, even if it has CausesValidation set to false. The control is outside the UpdatePanel, so I'm not sure what causes this. It is a frequent problem, as can be seen on Google.

I am looking into it now, so far, I have a simple solution that works:


function forcePostback(control)
{
	var old = Page_ValidationActive;
	Page_ValidationActive = false;
	__doPostBack(control, '');
	Page_ValidationActive = old;
}

When I have more information, I will post about it. If you happen to know the problem and its solution, please drop me a line!

Bookmark and Share

                             

4 Comments

  • Good in Update panel if we load control dynamically from different project like class library then Event not fire of control loaded dynamically event though javascript not load from that control any idea for That so we can achieve this

  • kirtidarji:
    Can you give an example code?

  • Just ran into this problem myself. Here's what I ended up doing...


    function forcePostback(control) {
    //force validators to validate themselves
    Page_ClientValidate("someValidationGroup");

    //or if you just want to force a specific validator, then call: ValidatorValidate(someValidatorControl)

    //this line is needed to allow additional postbacks. Without this, the next time you try to postback, the postback won't work unless you do the event twice, like clicking the cancel button twice.
    Page_ValidationActive = false;
    }



    For more info, checkout this article (it's an oldie, but goodie)! http://msdn.microsoft.com/en-us/library/aa479045.aspx

  • (edit for my previous comment)

    function forcePostback(control) {

    //force validators to validate themselves

    ValidatorValidate(control);

    //or if you want to force all validators, then call: Page_ClientValidate("someValidationGroup") or Page_ClientValidate() for all validators regardless of ValidationGroup.

    //this line is needed to allow additional postbacks. Without this, the next time you try to postback, the postback won't work unless you do the event twice, like clicking the cancel button twice.

    Page_ValidationActive = false;

    }

Comments have been disabled for this content.