Development With A Dot

Blog on development in general, and specifically on .NET

Sponsors

News

My Friends

My Links

Permanent Posts

Portuguese Communities

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

Comments

kirtidarji said:

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

# September 11, 2010 9:28 AM

Ricardo Peres said:

kirtidarji:

Can you give an example code?

# September 18, 2010 3:53 PM

klee said:

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

<pre class="brush: jscript">

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;

}

</pre>

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

# February 11, 2011 12:20 AM

klee said:

(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;

}

# February 11, 2011 12:25 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)