onclick of a button creates a window, add to UI, I want to close this window using javascript ? please advice how to close this window using javascript after some timeout?
Button button= new Button("load Content",e->{
Window sub= new Window();
UI.getCurrent().addWindow(sub);
});
Try this:
setTimeout("window.close()", 5000);
// here 5000 ms refers to 5 seconds
Related
I have to open a modal popup on link click .In that popup i have to take some user details and on submit some server side code has to be executed and new popup is to be opened.But problem is that on button click new popup opens and as soon as server side code gets executed second popup closes.
Expand your question as much as you it helps in understanding your problem
Anyways I guess your problem is that the page gets post back... You need to open your second Modal Popup from Server Side..
Here is a nice example of it: http://www.codeproject.com/Tips/215040/ModalPopupExtender-from-Server-Side-Code
write this in your codebehid button click event
popupid.Hide(); //hide the popup which you dont want to show.
//it will close when you click on submit button
popupid1.show();
write this in javascript
<script type="text/javascript">
var ShowVerifyInventory = '<%=popup_verifyInventory.ClientID %>';
function ShowPopUp_verifyInventory() {
$find(ShowVerifyInventory).show();
}
var HideVerifyInventory = '<%=popup_verifyInventory.ClientID %>';
function HidePopUp_verifyInventory() {
$find(HideVerifyInventory).hide();
}
</script>
In asp.net, I want to click on a button to open a popup windows. after the popup windows, I want to cause a full postback to the parent window.
How can I do this?
On your popup write the below script:
window.opener.PostBack();
// Where PostBack is the custom method of opener/parent window.
Either you can do it in OnUnload() event of your popup or from any other method followed by window.close();.
You can implement the PostBack() method like this in opener:
function PostBack() {
var btn = document.getElementById('<%=SomeButton.ClientID %>');
if (btn) btn.click();
// or
// __doPostBack('SomeButtonId','Arguments');
}
I am developing web application. In that i want to open one popup using thickbox after 5 seconds when user comes to entry page.
Can any one give some idea how to do this?
You can use the setTimeout() from javascript with the command from the thickbox, something like:
// when dom is ready
$(document).ready(function() {
// set a timer thats run 5sec
setTimeout(function(){
// open the pop
var me = $('#ElementToOpen');
var t = "title"
var a = "openurl";
var g = false;
tb_show(t,a,g);
},5000);
});
I have a function that does some database update in asp.net. I'd like a modal popup to show a "success" message for just 5 seconds after my function has been called. In this case, the modal popup would not be triggered by any "TargetControl" but would show up for just 5 seconds once the function is done.
Thanks
You can't close standard javascript modal dialogs (alert, confirm,..) after a timeout. Only manual close works with them.
But, you can use jquery/UI dialog:
// timeOut in ms
function showMessageWithTiemout(message, timeOut){
// show dialog
var successDialog = $('<div>'+message+'</div>').dialog({modal: true});
//close it after 5 seconds
setTimeout(function(){ successDialog.dialog('close'); }, timeOut);
}
//usage:
showMessageWithTiemout('success!', 5000);
You have to manually call the show method on the panel like:
var pnl = $find("<%= modal.ClientID");
pnl.show();
So you can use window.setTimeout to call this:
window.setTimeout(function() { /* code */ }, 5000);
But it can't just happen very easily.
HTH.
Is there a way to set a button inside the dojo dialog box and have it close the dialog box it is residing in?
Putting dijits inside of dijits doesn't work, and I can't beleive there isn't a way to do that.
Sure you can put a dijit widget inside another widget. And in a standard Dojo release there's even a test case Dijit Dialog focus & destroy included that demonstrates closing dialog with a button inside of it. Here's the relevant part:
var btn = new dijit.form.Button({ label: "Close" });
dlg.containerNode.appendChild(btn.domNode);
dojo.connect(btn, "onClick", function(){
console.log("destroying, while visible");
dlg.destroy();
});
Note, since Dojo 1.7 onwards, the connect module has been replaced with dojo/on. The equivalent of the above is therefore:
require(['dojo/on', 'dijit/form/Button'], function (on, Button) {
// etc
var btn = new Button({ label: "Close" });
dlg.containerNode.appendChild(btn.domNode);
on(btn, "onClick", function(){
console.log("destroying, while visible");
dlg.destroy();
});
});