How to close the dialog itself from the code behind? - c#

I create a dialog with in .aspx. This dialog is to update something and show the progress and I want it close automatically when the update is done. So can I close the dialog from the c# code without clicking the "Ok" or "Cancel" button when something is done?
I opened this dialog using a self-made dialog class of my company. I put a "neatUpload" element into this dialog so it can upload some file from the client machine to the server. What I want to achieve is close the dialog when the uploading is done. I don't know whether it is possible or not.
Thank you

You can't shutdown a client-side script from a server-side. It's not a desktop app, web apps work differently.
EDIT:
Maybe there's a way, based on your edit... I suppose you could use ajax to notify the client after the job is done and then use javascript in the dialog to close itself.

It depends on the kind of dialog you're using, if it's a window.alert, it cannot be closed other than by clicking on the 'OK' button.
You will need a JQuery dialog or such to achieve your goal.

Related

close an open tab in browser from C#

is there any way to close a tab on CHROME, Firefox and IE from C#? I believe that I can accomplish this via JavaScript but I do not know how to call a JS from my C# application. By way of background, my app opens a browser, interacts with the caller then I need to close the open tab.
You probably won't be too successful trying to close a specific tab in the opened browser. You could try to call Process.CloseMainWindow on the launched process, but this may get tricky and potentially close other tabs.
You may want to consider creating a new window (WPF) or form (WinForms) in your app and use the embedded browser control.
If the page you're opening is an asp.net you that you can code... In the method which you want to close the tab, use:
Response.Write("<script type=\"text/javascript\">window.close();</script>");
Otherwise, I can't think of a way either.

Windows Phone 7 Dialog

How can I show a dialog message, similar to MessageBox, which have just the "Cancel" button and can be closed by the application.
The idea is to show the dialog while the application retrieves data from a server, allowing the user to cancel this request, and closing the dialog once the request is completed.
I recall having a very similar problem in the past. I don't think there is a dialog message "out of the box" that works like that. The way I solved this was by writing a class that modeled this sort of behavior in a window and having the application spawn an instance of the window.
The silverlight message box blocks code execution while it is open so it is not possible to close it. However you can use an XNA messagebox in Silverlight which is asynchronous
This explains its use in depth
You can probably then call EndShowMessageBox for your purposes.
if your intention is to let the user know that something is loading and that they should wait. you should use a progressbar instead.
How to: Create a Custom Indeterminate Progress Bar

How do I detect which button was clicked on "save/open/cancel" dialog?

I got a webpage where members can download different kind of files on. I wan't to get information about which files and how many times each member have downloaded. when the user want to download a file he get browser pop-up where he gets 3 choises: "Open", "save" and "Cancel".(file dialog box in browser). i want to update the download status only if open/save button is clicked
Is there a way to detect which button was clicked on "save/open/cancel" dialog?
You can't know that. Some browsers even start the download before the user decides what to do with the file. But perhaps you can get your webserver to log if the download has been completed. That's probably the most reliable result you can get.
There is no way to know which button was clicked.
I dont think you can. The site just streams the file to the browser. What the user does
with the file is not known by the website as there is no more server side
interaction.

Integrate C# Desktop Application With Browsers

I have developed an application(downloader) using C# now i want to integrate it to browser like i want to place a button in browsers if user press that button then my app should execute & start downloading the required file.
I'm largely guessing, but it sounds like you are talking about a "protocol handler", i.e. to handle hyperlinks to "yourapp:some-stuff-here". If so, try looking at Registering an Application to a URL Protocol on MSDN, which gives a C# example of this.
I don't think that what you want is possible, you can however place a link to the executable and tell your users to execute it via the Browser download options (The Dialog that pops up when you click on some download link that asks wether you want to open oder save the file).
It is not possible to immedatly run your GUI application on a browser button click.

Opening a file in C# using a modeless openfilediaglog box

I'm trying to make a video recording application for a project and was wondering if there was anyway to make the OpenFileDialog open up in a modeless diaglog box or would I have to make my own custom version? The reason I ask is the ShowDialog() function freezes my video. Thanks in advance for the help.
Yes, you can prevent a file dialog from blocking the UI thread, but it can be rather non-trivial depending on the details of how you want it to behave. If you're open to buying a component that does this automatically, ComponentAge offers one. Otherwise, you can roll your own by opening the dialog on a spawned thread. If you want the dialog to appear modal to the form that opened it, you'll need to do some extra work to trap the handle of the opened dialog so that you can set focus to it when the parent form is activated. An example is available at http://www.codeproject.com/KB/dialog/CustomizeFileDialog.aspx.

Categories