Oct 06, 2013, 12:11 PM
I understand a bit more why the sample code I gave you before didn't work the way I expected, but I am still having a case that I cannot produce in a sample where -= doesn't work, so I've resorted to setting Before="return false;". However, I found another situation where Confirmation will still show even though.
This will deactivate the OnEvent from ever being triggered, but not the ConfirmRequest. It's kind of frustrating that presently if I want to turn off the click event in the server-side, I have to deactivate both the Click Event Before="return false" and set the Confirmation.ConfirmRequest="false" just to prevent confusion to the user.
In the meantime, till you guys have a more robust situation, the following extension method allows me (or anyone) to reliably Disable any event Event as long as its a part of the Page_Load(). I'll have to wait till you have a solution on the DirectEvent side.
<ext:Button ID="Btn" runat="server" Text="Test">
<Listeners>
<Click Handler="alert('test');" />
</Listeners>
<DirectEvents>
<Click OnEvent="OnClick" Before="return false;">
<Confirmation ConfirmRequest="true" Message="Are you sure?" Title="Confirm" />
</Click>
</DirectEvents>
</ext:Button>
This will deactivate the OnEvent from ever being triggered, but not the ConfirmRequest. It's kind of frustrating that presently if I want to turn off the click event in the server-side, I have to deactivate both the Click Event Before="return false" and set the Confirmation.ConfirmRequest="false" just to prevent confusion to the user.
In the meantime, till you guys have a more robust situation, the following extension method allows me (or anyone) to reliably Disable any event Event as long as its a part of the Page_Load(). I'll have to wait till you have a solution on the DirectEvent side.
public static void DisableEvent( this ComponentDirectEvent evt ) {
var before = evt.Before;
if( !string.IsNullOrEmpty( before ) )
evt.Before = "return false;;" + before;// 2 semicolons are used to indicate intensional override
else
evt.Before = "return false;;";
if( evt.Confirmation.ConfirmRequest )
evt.Confirmation.ConfirmRequest = false;
}
public static void EnableEvent( this ComponentDirectEvent evt ) {
var before = evt.Before;
if( !string.IsNullOrEmpty( before ) && before.StartsWith( "return false;;" ) )
evt.Before = before.Substring( 14 );
if( evt.Confirmation.ConfirmRequest == false && !string.IsNullOrEmpty( evt.Confirmation.Message ) )
evt.Confirmation.ConfirmRequest = true;
}
Last edited by michaeld; Oct 06, 2013 at 12:13 PM.