View Full Version : Update handler for button

Aug 25, 2015, 9:28 AM
Hello. I have the following markup:

<ext:Button ID="RefreshDoc" runat="server" Icon="Reload" >
<Click OnEvent="RefreshDocument" Type="Load" Method="POST" Success="doStuffAfterSuccess();">
<ext:Parameter Name="Id" Value="#{Id}.getValue()" Mode="Raw" />
<EventMask ShowMask="true" MinDelay="500" />

<ext:Button ID="ShowChildButton" runat="server" Icon="ClockGo" Text="Show Child" >

This is the RefreshDocument method:

public void RefreshDocument(object sender, DirectEventArgs e)
var id = e.ExtraParams.ToDictionary(o => o.Name, v => v.Value).ToGuidId();
if (id == Guid.Empty)
this.ShowChildButton.Disabled = true;

// skip url building for brevity
this.ShowChildButton.Disabled = false;
this.ShowChildButton.Listeners.Click.Handler ="console.log(1);"


As you can see, I send Id, sometimes it can be empty. And when it's empty then button is disabled. After some other actions Id can be filled and when I click `RefreshDoc` button then `ShowChildButton` shows and clickable, but the handler doesn't call.
Where is a problem?

PS. It looks like handler doesn't exist in the response, only disabled/enabled properties (I skipped some strings for brevity):
{script:"Ext.net.ResourceMgr.registerIcon([\"FolderPicture\"]);ShowChildButton.setDisabled(false); ... }

Aug 25, 2015, 11:34 AM
Hi @sharok,

Welcome to the Ext.NET forums!

Yes, a Button's Listeners is only taken into account before rendering. If a Button is rendered, it doesn't produce any effect.

Please have a look at this post. There is a few suggestions how to attach listeners on the fly.