event-handling

ASP.NET: Postback processed without events being fired

柔情痞子 提交于 2019-12-08 07:10:57
问题 I have a GridView with dynamically created image buttons that should fire command events when clicked. The event handling basically works, except for the very first time a button is clicked. Then, the postback is processed, but the event is not fired. I have tried to debug this, and it seems to me, that the code executed before and after the first click is exactly the same as for any other clicks. (With the exception that in the first click, the event handler is not called.) There is some

Removing event handler with .off

China☆狼群 提交于 2019-12-08 06:56:42
问题 I am unable to remove the event handler using .off for the boxes. Once a box is clicked I need the event handler removed for that box, currently I have made the hook ".clickable" and remove the class and tried to remove the event handler then apply the event handler back to all boxes with a class of ".box". $('.clickable').off('click','**').on("click", function(event){ if( !$('.box').is(':animated') ) { var position = $(this).position() , targetPosition = $('.target').position(); $(this)

Handling Button gesture for both single and double click/tap

旧巷老猫 提交于 2019-12-08 06:45:24
In Xamarin Forms: I want to be able to detect both click/tap and double-click/tap, and to be able to perform different actions. That is, when the button is clicked I want to perform actionA , and when the button is double-clicked I want to perform actionB , and only actionB . Do you need an actual button? Else look at the TapGestureRecognizer . In this post is described how you can use it. You can apply it to virtually any control. For example if you would style a Label to look like a button, you would add a double tap recognizer on it like this: <Label Text="Tap me, I double dare you"> <Label

Why is a variable defined locally successfully accessible from within another function?

爷,独闯天下 提交于 2019-12-08 06:19:01
问题 See code below. Put both files in the same directory and run Form1.ps1 from the PS ISE As you can see, the (local) variable $localVar is defined in the event handler $button2_Click . As such, I assumed $localVar would not/could not exist outside the scope of $button2_Click with scope defined by the braces that define the event handler. However, as you can see, I use the contents of $localVar to load $textbox2.Text in the function fA . When you click the Test button, both textboxes display the

When should we use event in C#

こ雲淡風輕ζ 提交于 2019-12-08 06:02:09
问题 I am a newbie of C# and WPF. And I just learned the asynchronous programming in C#. We raise event and some where we catch this event. The advantage of this method is we don't need to call directly the object method. Example we load data from database, then after load data method is finish, it raise the event LoadDataSuccessfully Then the main class catch this event and raise event UpdateGUIAfterLoadDataSuccessfully , some other Control will catch this event and update GUI. But now I think

Detach event handler after attaching method with passed parameter

久未见 提交于 2019-12-08 05:55:42
问题 I need to pass a parameter (in C#) to an event handler and then be able to detach the event handler. I attach the event handler and pass the parameter: _map.MouseLeftButtonUp += (sender, e) => _map_MouseLeftButtonUp2(sender, e, showResultsWindow); The event is called as expected. I try to detach the event handler: _map.MouseLeftButtonUp -= (sender, e) => _map_MouseLeftButtonUp2(sender, e, showResultsWindow); The code executes without error, but does not seem to detach. If I attach the event

Best practices for callbacks within a scope

馋奶兔 提交于 2019-12-08 05:33:55
问题 Typically, in "constructor" you subscribe to events with lambda-functions: function Something(){ this.on('message', function(){ ... }); } util.inherits(Something, events.EventEmitter); This works well but extends bad. Methods play better with inheritance: function Something(){ this.on('message', this._onMessage); } util.inherits(Something, events.EventEmitter); Something.prototype._onMessage = function(){ ... }; What are the best practices to keep these event handler functions? 回答1: if i

Passing on:click event into dynamically created <svelte:component/>

心不动则不痛 提交于 2019-12-08 04:37:33
问题 I basically need to be able to trigger something within one or more components (that are being dynamically added via svelte:component) when an icon/button within the parent component is clicked. e.g. I need to hook the parts denoted with ** below:- <script> let charts = [ ChartA, ChartB, ChartC ]; </script> {#each charts as chart, i} <div class="wrapper"> <div class="icon" on:click={**HowToPassClickEventToComponent**}></div> <div class="content"> <svelte:component this={charts[i]} {*

How do I get JavaScript code in a bookmarklet to execute after I open a new webpage in a new tab?

旧巷老猫 提交于 2019-12-08 04:15:57
问题 I'm trying to figure out how I can get my bookmarklet to work the way I want it to. Here's my issue. I have a JS bookmarklet that scrapes a secure webpage and uses those DOM elements to run my code. My issue is, when I click on my bookmarklet, it opens the new page in a new tab and immediately starts running the code I intend to run for the newly opened page. For example, a prompt window that I'm using to store user input runs immediately on the current page I'm on when I click the

Parent JPanel - How to listen to the events generated by components of a Child JPanel? [duplicate]

梦想的初衷 提交于 2019-12-08 03:19:05
问题 This question already has answers here : Adding ActionListener to a Panel - Panel implements ActionListener vs Panel HAS A ActionListener (2 answers) Closed 6 years ago . I made a JPanel Child which contains a couple of radio buttons in it. Whenever a radio button is clicked i want an ActionEvent to be generated from the Child also. This action event should "contain" a reference to the button which actually generated an event. This Child will be used as a component inside another JPanel