Refreshing contents of a Modal Dialogue - c#

I have a row of buttons on a web page, each of which is to invoke a Model dialogue to display further details. I am displaying the modal dialogue thus:-
winArgs = window.showModalDialog('MyDialogue.aspx', winArgs, winSettings);
and when I do this, the codebehind detects the data it is supposed to display and displays it on the Modal dialogue. I then close this down with the red X, and click another button to display a different dataset, but no codebehind methods are invoked, and consequently the dialogue displays the previous dataset.
I guess there is nothing that can be done about this on closing (that is a client event), so what I need to know is how do I either:-
create a new modal dialogue with the showModalDialog and not re-use the existing one,
or, invoke some function in the code-behind when the dialogue pops up?

Related

Keep toggle button from one form ON when switching to a different form

So basically, I have a C# winform and it has multiple pages (which are different forms) when going to one page to another it closes the previous form/page. However, I have a “Settings” page and on that form I have a toggle button. That toggle button changes the text of a label on form1. If I force the form the open while the “settings” form is open, the text changes. However, I do NOT want that form to actually open I just want the text to change but when I take out the form1.Show(); , and just toggle the button off and switch back to form1 the text is the original and when switching back to settings, the toggle button has re-enabled itself. I cannot figure this out.

Asp.net MVC 4 Keep TempData only on Page refresh?

I am using a dialog box to confirm an action that requires an override by a user's supervisor. When the dialog box pops open the form values are pre-populated with TempData in the view and the text boxes are locked (disabled); except for the text box the supervisor uses. The logic is set to deactivate the lock upon a submit, cancel, or on close event of the dialog box. So the next time the user opens the dialog the text boxes will be enabled and blank for a new submission.
Now, in the event a user refreshes the page (for whatever reason that may be) while the dialog box is opened and in the locked state, the TempData value life cycle ends and when the dialog box is reopened, then the text boxes are in the locked state but empty. So the system is ready to submit a form with a supervisor approval that has empty values.
Now, my question is, on a page refresh, is there some final method that is called to where I can call keep on the TempData? Or what is the best way to retain the TempData only in the event of a page refresh? thanks!

Focus lost when IPleaseWaitService is called before a modal dialog using Catel

In summary, I do have a modal dialog in Catel, invoked with:
_uiVisualizerService.ShowDialog(viewModel)
Inside that dialog, I do a long process showing a Wait Service:
_pleasewaitservice.Show();
// HARD WORK here
_pleasewaitservice.Hide();
And Then I invoke another modal dialog.
_uiVisualizerService.ShowDialog(configureViewModel)
However, when I click outside of the application while it is doing the hard work (when the pleasewaitservice is shown), the second modal dialog is displayed behind the main application, so I cannot focus the Window because it is behind and it is modal. I have to close the app from the task killer.
After checking it carefully, I realized that origin is the pleaseWaitService. If I don't show it, the second modal dialog is always displayed correctly.
Does anyone have any hint about how to solve it?
I was googling about how to force to set focus in any Window, but I didn't find anything.
Thanks
Regards
Saul Hidalgo.
You might want to try the BringWindowToTop extension method inside the code-behind of the window:
https://github.com/Catel/Catel/blob/46fcc69575e533eb9e02669ebaa2246894dc98d8/src/Catel.MVVM/Catel.MVVM.Shared/Windows/Extensions/WindowExtensions.cs#L237

Ability to navigate back with browser button without showing control alerts message boxs that appearing in the middle of the navigation process

I am searching for techniques/ approaches to solve this problem:
dummy scenário:
In main page I have a button. when I click on it, it display a message: "are you sure?"
when I click ok... it redirect me for secondary page. Now if I want to go back, I click in back button of the browser... my intended behavior is to the application go to main page... but instead it show the alert box "are you sure"...
the same appens in forms...when I click back the application keep point me to the previous input instead of go to the previous page.
I suppose that is a dummy question... but for this context I don't have the knowledge for "googling" the right Keywords... so point me in the right direction it will be a huge Help;)

How do I make a custom modal popup window in WPF and have it return a value?

I'm taking a whack at WPF and trying to learn as I go. I'd appreciate any advice offered.
I've got a Window that has a Page attached to it (through a Frame on the Window). When you press a button on the Page, I want a custom window to pop up to present several custom options and be displayed in a manner of my choosing (I'm thinking right now I want it to be a grid but that may change as I go on). When selected, the modal window will disappear and return to the calling method (button press from the Page) the value of the selected choice.
I don't want the standard windows dialog box with the options of yes, no, okay, cancel, or anything like that. This is truly just a custom popup that returns a value to the caller when the user makes their selection on the popup.
Create a new Window subclass, which you can layout however you like. Then in your button click event handler, display it modally using myModalWindow.ShowDialog();. You can then have a property on the window class which you can access after it closes in order to access result data, i.e.:
myModalWindow.ShowDialog();
var data = myModalWindow.SomeResultProperty;
If you really want to have something returned from a method, I suppose you could create your own public method on your window class which internally calls ShowDialog() and then returns a value.

Categories