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>
Related
I have a page where the user can enter data and on submit, it shows up on a gridview right below it.
How do I prevent double click. I understand I can disable the button but that would defeat the purpose as then, the user cannot enter more information without refreshing the page.
I add a class to all elements I dont want the ability to add a double click
$('.disableDoubleClick').dblclick(function(e){
e.preventDefault();
})
this question has been answered many times, just google disabling double clicking in asp.net
You could always disable the button and then use setTimeout to re-enable the button after second or two: http://jsfiddle.net/BJKy4/
$("#btn").click(function () {
var button = $(this);
button.prop('disabled', true);
setTimeout(function () {
button.prop('disabled', false);
}, 1000);
});
I have a bootstrap page that lists items in a table. Each item has its own delete link that launches the modal.
<a href="#modalDel" data-idtodelete="<?php echo $value->id; ?>" class="deletelink">
Delete this item
</a>
...
jQuery("a.deletelink").click(function(event){
var id2del = $(this).data('idtodelete');
jQuery("#myModalLabel").html("Delete item: "+id2del); //works great
jQuery('#modalDel').modal('show');
});
I can pass data to the modal easily, but now I have to make the main button in modal to reflect the dynamic url and call to it (only) when this button is clicked
Any ideas? Thanks
PS: cannot use the hidden event for this, because modal can also be hidden with the cancel button. Also, modal should be closed after/before calling the dyn. delete url of main button
I'll hazard a guess at this. Haven't tested because I'm not really sure about the setup.
var $ = jQuery; // using as a shortcut
$('#modalDel').on('show',
function() {
// Composes delete URL with arguments
var dynUrl = composeUrl(args);
// assuming the modal button is an anchor element
$('#modalButton').attr('href', dynUrl);
// Also closes the modal box after being clicked
$('#modalButton').on('click',
function(e) {
$('#modalDel').modal('hide');
});
});
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 took the JQuery UI dialog form sample from JQuery UI website.
Since I wanted that, once the dialog is opened and the form is displayed, that pressing the key submits the form, I added the following in the onReady() :
$.extend($.ui.dialog.prototype.options, {
open: function() {
var $this = $(this);
// focus first button and bind enter to it
$this.parent().find('.ui-dialog-buttonpane button:first').focus();
$this.keypress(function(e) {
if( e.keyCode == 13 ) {
$this.parent().find('.ui-dialog-buttonpane button:first').click();
return false;
}
});
}
});
This does perfectly the trick (I mean the click() is triggered when it has to), but the following occurs :
When the form is first submited through a press on the key, the submission is performed once.
If I reopen the dialog, and submit it again with a press on the key, the form is submitted twice.
If I reopen the dialog, and submit it again with a press on the key, the form is submitted three times, and so on...
This can be tested with the following fiddle :
http://jsfiddle.net/fWW2E/
Let me add that doing so by clicking on the dedicated "Submit" button works properly, this fails only when pressing the key is involved.
Any ideas ?
Thank you !
Because since you're assigning this on "open" and your buttons are "closing" the dialog.
When this gets called though:
$('something').dialog('close');
doesn't actually remove the element, it just hides it. So the next time you click to open up a "new" dialog, you're really just showing the first one again. However the "open" event is getting fired again every time it's opened, which is adding a new keypress handler onto it.
Here's the fiddle. I actually write out to the console an array of the current handlers on that element. You'll see everytime you open the dialog that there is another keypress handler.
DEMO
I have a webform and i want to detect if F5 button was pressed or if the page was refreshed. I know about postback but it is not what i'm looking for. I have a gridview that loads in a modal popup when a button is clicked and a parameter's value is set for the gridview. When refresh is hit and if the modal popup button was previously clicked the modal popup is visible right after refresh. I want to detect if the page is refreshed to prevent this. any ideas? I thought to try Override but I'm not exactly sure how to use it. I tried Control.ModifierKeys but I don't have access to ModifierKeys.
Pressing F5 or physically clicking the browser refresh behaves similarly to navigating away from the page. This is captured in the event window.onunload. Try the snippet example below:
window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}
This will capture the refresh and allow you to do something or prompt the user.
Reemember that hotkeys are processed in the client side in the browser. The easiest way to implement this is through javascript.
Look at the following link:
http://snippets.dzone.com/posts/show/3552