I almost feel bad asking this stupid question, just upgraded to VS2012 from VS2008 and I started out by create a new Web Forms Application, and bang there you go a bunch of files and folders created. When I view the Register.aspx page, there's this line:
<asp:Button runat="server" CommandName="MoveNext" Text="Register" />
and when I run this application, it actually works, it creates a local DB and the user are inserted into that DB.
But HOW? I see no click events, I see no function in the code behind handling the MoveNext command, is this some kinda of new way of handling events? Where does the magic happen? Thank you guys
It seems like a bit of magic but it is part of the ASP.NET 4.5 Framework. It is the CreateUserWizard control on Register.aspx, there is an attribue called OnCreatedUser that wires up the code behind "click" event you are looking for. Should be called RegisterUser_CreatedUser.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.createuserwizard.oncreateduser.aspx
It's all part of the CreateUserWizard control. If you disassemble that class, you'll find a bunch of code that knows how to hook up to your markup. My guess is somewhere in there is something that attaches the MoveNext command to an event handler inside that user control.
When your button does a postback on the page, the lifecycle for the control is executed, so somewhere in that lifecycle is all the work.
Related
My question is very basic on one hand but on the other hand the general situation is more complex, plus I cannot really get any working sample.
I'm developing/maintaing a web-application which is currently in transition from GWT code base into Ember.js.
Most of the newer code already relies on Ember.js and I think it's really awesome.
The problem is we cannot use Ember Router as all the request are being handled by the GWT.
In order to enabled the application run in this unusual configuration we have special JavaScript files that create our Ember main objects (Controllers & Models) for us.
As you can imagine navigation between tabs is cumbersome and is handled by GWT who creates Ember objects when needed. We are in transit toward a brave new world Ember Router and all.
But in the meantime, this is the problem I'm facing right now.
The user clicks a link which opens a page that contains some Ember based table.
The data is retrieved form the server using some Ajax code. Upon success it spawns a forEach loop which tries to pushObject all the received date into our Ember based components.
My problem happens when the user quickly switches between tabs. In this case the first list of object has not finished rendering yet and suddenly there's a new set of objects to handle. This causes Ember to throw errors like:
"Uncaught Error: Cannot perform operations on a Metamorph that is not in the DOM. "
and
"Uncaught NotFoundError: An attempt was made to reference a Node in a context where it does not exist."
Is it possible to prevent the loop from trying to render?
I've tried checking if the controller in question is already inDOM and it is, is there a way to notify Ember this object is no longer valid?
Sorry for a lengthy question and lack of running sample.
I'd probably modify the switch tab code to only execute afterRender has completed, that way you aren't mucking with ember objects while they are being used.
Ember.run.scheduleOnce('afterRender', this, function(){
// call GWT switch tab routine
});
Thank you Daniel and Márcio Rodrigues Correa Júnior. eventually what I did is to add a patch that would check the current context of the application (in my case the currently selected tab). If upon receiving the AJAX response the application is in the correct context (meaning the user haven't change the tab) go on. Otherwise just ignore the response and do not try to render it.
Now it seems to be working
Beginner / Intermediate developer here and trying to get a grasp on tracking down event listeners, but finding myself confused and frustrated because it always point to the library that handles the event, not the user's script. Example from the Event Listeners accordion on a select element that has the "keyup" event bound:
keyup
div.select
handler: function (e){return typeof b===i||e&&b.event.triggered===e.typet:b.event.dispatch.apply(f.elem,arguments)}
isAttribute: false
lineNumber: 3
listenerBody: "function (e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)}"
node: div.select
sourceName: "https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
type: "keyup"
useCapture: false
Obviously they are using jQuery, and they're doing a damn good job of it by using jQuery's $.extend method, but I still don't understand why the events accordion (in dev tools) would point to the library rather than the customized script?
Is there something really basic I missed in class? What methods are there for tracking these types of things down aside from CTRL+F in the Resources tab, which, btw did not yield any search results for "select" in the file that ACTUALLY extends/adds this listener - very odd is it not?
Update: So I feel pretty dumb about this, but the answer was right in front of my eyes - or so I think. At the top of their custom script they begin with,
define(["jquery"], function($) {
Could this be the beginning of the answer? Really what I'd like to understand is why the event would still trace back to the library when the event listener is bound within the above code,
$el.textHolder.click(function(e){
... do stuff ...
}
As far as I understand, this is because when jQuery binds an event, it doesn't bind it directly to your code, but instead to jQuery code that then dispatches the event to your code.
The Chrome devtools don't know (at this point, it seems to be in development) how jQuery binds the event, so only shows the first handler (jQuery).
The define call is part of the CommonJS Modules Standard I believe. See also RequireJS
I am trying to port a WinForms app for use with Mono, and I've recently noted that calling Form.Show() from another form will either do nothing or cause the new form to flash and disappear. I read something about the new form needing a message pump, which is accomplished with Application.Run(), but that's already been called. Any idea why this doesn't work? I can't use ShowDialog because my program relies on events fired by completed async tasks, and I don't want to block a ton of extra threads that will be done right after the Show call.
Have you tried to hide your current form before showing/displaying your new one?
Seems to me like your form is indeed being displayed but for some strange reason it's being delegated to the background. Worth a shot.
Im hours and hours finding why one of my ZEND plugin sometimes running twice (depends on URL)
Note that my plugin has preDispatch and postDispatch methods and when I debugging the code it works like this:
MY_Plugin:preDispatch (echo $_SESSION['DBG'] has value)
MY_Plugin:postDispatch (unset($_SESSION['DBG']))
and then again
MY_Plugin:preDispatch (echo $_SESSION['DBG'] not exist)
MY_Plugin:postDispatch
This is part of bootstrap code
$_SESSION['DBG'] = 'value';
$MYrouter = new MY_Router_MyRouter();
$frontController->setRouter($MYrouter);
$frontController->registerPlugin(new MY_Plugin());
Do you have any suggestion how this could occur or how can I simulate this.
Thanks for any suggestion
Cervenak
Thanks guys for lot of valuable hints.
Now watch my story :)
First I had turned off showing exceptions (parameter False). So I switch them ON to see exception notification.
$frontController->throwExceptions(true);
Than I saw that I dont have uploaded controller and view files. After uploading them ZEND started to work corectly.
Good to know to have this direction set ON during debugging. You could probably save hours.
The dispatcher loop most likely running twice (the controller is dispatched twice). Possible causes:
using action view helper
calling _forward
redirector action helper
manually calling dispatch()
dispatch loop aborted and started again (eg. resetting request params)
Also, take a look at this ZF flow diagram (hotlinked from php-professionals.com)
Another reason could be an missing favicon.ico :-)
If the Apache cant find it, it fires a second request.
I eventually couldn't get any further with my program due to the various shortcomings of VB.NET (bad audio support, no reading events in the middle of execution, very weak keyboard input, etc). So I tried SDL.NET 6.1.
Despite its terrible documentation, I was able to fix my code to use it and I love it!
But there's a problem. I don't know how to set up my application settings for it. The Startup Object definitely should be a class (the examples always are in classes, never modules), but a startup class specifically has to be a form! This is bad because SDL makes its own window via SetVideoMode; you don't need a form. So when the form constructor New() finishes, a useless form is created and you have two windows.
I tried placing a call to the game engine loop within New() so that the game starts up without New() ever finishing. The game runs normally, and this solves the "second window" problem... but it can't be closed! X button does nothing, calls to Events.QuitApplication or Me.Close are blatantly ignored, etc.
I'm stumped. It seems I need to set a non-form class as the startup object, but it won't let me.
Oh, by the way, it seems that there are two things called "SDL NET". To clarify, I'm using this one, which exists in the SdlDotNet namespace.
Oh, I forgot to mention, I also noticed that a lot of the examples have a line that says "[STAThread]". Is this is important?
EDIT:
I've already received and accepted an answer for my question, but I want to tell other people what the problem is with exiting/closing the app, even though that wasn't my question:
While SDL.NET allows you to receive input and run other events without having to stop running logic, the application still cannot quit while logic is being run. So I find the best way to tell your SDL.NET application to Quit in the middle of running logic is to use the following TWO lines:
SdlDotNet.Core.Events.QuitApplication
End
Place these in the handler for the SdlDotNet.Core.Events.Quit event, as well as anywhere else you want your program to quit.
The Startup Object definitely should be a class (the examples always are in classes, never modules)
Here's your mistake. There's no real difference between a class and a VB module from CLR perspective. So just make it a module with Main and go on. There is no need for a class. I suspect you're looking at C# examples, which use classes - but that's because there is no such thing as a module in C#.
[STAThread] probably won't make any difference for SDL. It is important for UI applications (both WinForms and WPF require it), but I don't think that SDL does any COM calls, so it shouldn't care whether your thread is STA or not. It's just something that Visual Studio puts on Main in new projects by default.