how to debug delete button action in Lightswitch?

2019-09-02 18:48发布

问题:

I am supposed to find a bug in Lightswitch C# application written in VS2012 which causes application to hung when delete button is clicked. I am new to LS and have problem figuring out how to find the internal code is executed when that button is selected. Even when I try to override action of this button debugger doesn't stop there. Debugging just my code is turned off, on screen data binding I see some name I cannot find in the code. Anybody here has some experience with lightswitch to point me to right direction? thanks

回答1:

Lightswitch HTML uses JavaScript for the code behind, not C#. An example of a typical LS delete command:

screen.Items.deleteSelected();

Debugging can be a bitch at times, often i find i have to place breakpoints AFTER running the application. Alternatively, you could use a crude debugging method and insert a bunch of alert() methods in the JavaScript. It's not pretty, but it's effective.

Note: The delete code could be calling a WebAPI web service, or running SQL against a database. In both these scenarios you will need to separately debug these.