OOB NewForm in Dialog loses focus after a few seconds - sharepoint-2010

Working in SharePoint 2010, with SharePoint Designer 2010, I have a DispForm to which I've added a DVWP that displays a filtered view of another relative list. The DVWP has a 'New' link which opens the NewForm for that list in a modal dialog, using OpenPopUpPage (http://msdn.microsoft.com/en-us/library/ff410825.aspx).
After 5 - 12 seconds, the blinking cursor disappears from the first control and the focus switches to the 'Close' button. If the user was trying to type and happens to hit the Enter key when the focus switches to the 'Close' button, the background is no longer darkened and the 'Cancel' button no longer works. The form is still displayed on the screen, and the user can 'Save' but the modal never goes away until the page is refreshed.
If the user notices that the modal has lost focus and clicked back on the form, everything works as it should and all is well.
Observations:
When the control/modal loses focus, the 'Close' button does not trigger a 'focusin' event. But, $(document.activeElement).attr("value") displayed in the console shows that it's the active element.
Questions:
Why is the modal losing focus?
Does anyone have a Javascript/jQuery workaround to capture the event and set the focus back where it was?
Alternately, what if I lock the form and wait for this focus-change to complete, then unlock it and set the focus on the first field? Ideas?

You may be having a problem if the DispForm is also a dialog and you open the modal with your script. It sounds like you are getting a "layered" effect. My guess is that the script managing the dialog is interfering with the modal. Have you tried turning off the dialiogs for the list?

Just so I get some points on this site, the affliction was the asynchronous refresh of the first modal. It was taking the focus away from the layered modal.
Thanks JB for the answer!

I figured out the problem: the DVWP was using Auto-Refresh with the Async Update. This was running every 15 secs, taking the focus away from the modal, then not returning it to the last control.
So, we turned of the auto-refresh and used the callback from the modal close to trigger a click on the manual refresh button instead.

Related

Form from external DLL does not Show after being minimized

This is probably behavior by design, but I'll ask anyway -
I call a form from another project dll in my main project. It is NOT Modal (ShowDialog) or TopMost, and I set a variable for the form once it's created ("frm = New ..."), so that I can check when it's already been created (user clicks a toolbar button to create it initially.)
The form displays, fires events etc. all perfectly.
However, if I MINIMIZE the form and then call frm.Show through code to bring it back, nothing happens. The form remains minimized.
frm.Show has no affect and doesn't seem to fire any other events.
The only way to bring it back is to click on the taskbar icon for the MAIN form, which then displays the MAIN form AND the minimized forms (as icons), and then click on the icon for the minimized form.
I've tried various events (.Activate, .Show, .ShowDialog, .Focus) NOTHING will bring the other form out of its minimized state other than physically clicking on the Taskbar MAIN app icon and then selecting it.
Also, the main application is not MDI...
???
Thanks.
normally this should do it as suggested by #jimi
[TheForm].WindowState = FormWindowState.Normal
But sometimes this does not works for some dark reason, so you could use some other methods
form.Show();
form.BringToFront();
if (form.WindowState == FormWindowState.Minimized)
{
ShowWindowAsync(form.Handle, 9); // 9 = SW_RESTORE
}
I am sure there is one of these that will fix your problem

tabindex not being set when textbox has focus

I have a textbox that when focused it calls an ajax request and populates a list for the user to choose from. Basically just recreated the dropdown using a textbox instead of a select.
The problem is that if I click on the textbox the browser does not recognize the tabindex of the input. Instead it resets its self and starts back at 0. If I tab to the next element tabs work fine, only when I click in the input field to give it focus does it start acting up.
I did notice last night if I put an alert in the page on the focus event that it seems to work. Guessing because the browser focuses on the elememt after I click the ok button.
has anyone heard of this before?
found what was causing the problem. I was calling .blur() on keydown and code was 9 or 13 (Tab/Enter). Not sure why this would give me the problem I was having. I would have just thought the blur event would have executed twice. However I suppose that I was forcing blur on keydown and the current tabindex was not being set. If this is the case then If I needed to I should beable to call blur() onkeyup event.

Form sent to back on interaction with menu item

I've got two forms, one being frmMain and the other being frmDatasets. The idea is that frmDatasets is used to manage the application's datasets (it's a program for comparing sorting algorithms).
I have a MenuStrip on frmDatasets with a few items. I just decided to change the Add Dataset item to a drop-down menu with options for loading one from file, or generating one according to certain parameters. All well and good; just add the items, swap some icons around, and change the event handler's signature to handle the right Click event.
Except when I run the program, clicking on the Add Datasets top-level item for the first time sends frmDatasets to the back, displaying an inactive frmMain. Clicking the item again shows the dropdown menu as usual.
If I instead click another top-level menu item, that works just fine. But then simply hovering my mouse over the Add Dataset item causes the 'send to back' thing to happen.
I say "send to back", but it's really just putting it behind frmMain. It remains in front of other windows like Visual Studio and Firefox.
Anyone know what on Earth is going on with this form?
EDIT: If I show frmDatasets as a modal dialog, it stops the whole "sending to back" thing, but I still have to click the menu item twice before it shows the list.
EDIT2: Overriding the onClick event to call mnuAddDatasetDropDown.ShowDropDown removes the double-click issue, but it's only a solution if I keep the form as a modal dialog. Still gets sent to back. Overriding mouseEnter doesn't do anything to solve it.
Setting the TopMost property of frmDatasets from its Design view to 'true' fixed all of the problems I was having. No insight as to what was going on, unfortunately, but if anyone else is having this problem then hopefully it'll work for them too.

Slow Response After Clicking Button in VB.NET

I have created a windows form on a Windows Mobile 6.5 application. This screen has a username and password field and a login menu button. After clicking the button, it takes my click event for the login button 6 or 7 seconds to reach the first line of code (an alert). It takes that long to reach the breakpoint as well.
I've tried:
changing the menu button to a login button
using AddHandler in my formLoad event
...and have still not gotten a fast response. What else could be slowing this down?
This delay seemed to happen the first time any button was clicked on the application. The only way I could get this delay to not occur was to force a dummy button click of the login button on load of the application. The delay causes the application to load a little bit longer, but at least that delay won't occur when the user clicks the button.

Application hangs on clicking "Choose" button in IKPictureTaker view

I am facing a strange hang issue with IKPictureTaker and on clicking a "Choose" button. I am doing below operation using IKPictureTaker.
When a user wants to change a profile picture, upon clicking "Change Image" button, I display a IKPictureTaker view along with "Choose" button by setting IKPictureTakerAllowsFileChoosingKey to YES.
First time on clicking the "Choose" button, open panel will be displayed allowing user to select an image of his choice.
Next, on clicking the "Set" button, internally I am calling a profile picture upload function of a server in a separate thread and everything works great.
Next if the user tries to do the operation 1) and 2) again application hangs on clicking the "Choose" button.
After investigation I found that this issue is something to do with the background upload operation I am doing with the server.Because if I comment the upload part of code everything looks good.
I don't see any issues with the upload operation performed in the separate thread and it gives up it s runloop once it is done with its upload operation and all UI related operations again taken care in the main thread.
Application hangs only if I click on the "Choose" button. If I select the recent pictures or take a new photo using the camera everything works great.
Is there anyone who faced the same issue? Is it something to do with the NSOpenPanel displayed when we click on the "Choose" button?