| Issue 114: | ASP.NET server controls Postback not working after nyroModal opened. | |
| 5 people starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. create a hyperlink with class="nyro" and reference any other page in
href tag
2. call nyroModal like: $('a.nyro').nyroModal();
3. click hyperlink on main page to open modal
4. close the modal window
5. try clicking any button, linkbutton, imagebutton that can postback and
nothing happens
What is the expected output? What do you see instead?
after closing the modal window, my ASP.NET controls on the main page should
still function normally
What version of the product are you using? On what operating system?
1.3.0 on windows XP using visual studio 2008
Please provide any additional information below.
using Firefox 3 but experiencing same issue in IE6 & IE7
not sure if the somehow the controls default postback functionality is
being overwritten, but I desperately need this functionality for an app I
am working on.
much thanks!
Nov 15, 2008
Project Member
#1
nyro...@gmail.com
Nov 15, 2008
Hi. thanks for the quick reply! I don't have a live sample for you to have a look at, but I can put something small together up on our test site by tonight if thats ok?
Nov 17, 2008
hi there. Unfortunately, Im unable currently to put something live up...hosting issues (dont ask!). but I can point u to these pages where people are experiencing similar problems with other modals, one of which is also my post on ASP.Net forums. http://forums.asp.net/t/1347338.aspx http://blog.hurlman.com/?tag=/jquery (note: its difficult to follow the solution outlined here) http://groups.google.com/group/jquery-ui/browse_thread/thread/8791be4f5969debc http://stackoverflow.com/questions/29174/simplemodal-breaks-aspnet-postbacks I know these mostly reference other modal plugins, but hopefully u can use the information to make your plugin work better than the others. regards
Nov 17, 2008
sorry, as well as: http://www.nabble.com/(ASP.net)-Preventing-postback-on-dialog-button-click-td18768485s27240.html
Nov 18, 2008
I think I got the problem.
Could you try that:
var oldForm;
$.nyroModalSettings({
endFillContent: function(elts, settings) {
oldForm = window.theForm;
window.theForm = $('#aspnetForm', elts.content).get(0);
},
endRemove: function(elts, settings) {
window.theForm = oldForm;
}
});
Please let me know if it's working.
Labels:
Type-Other
Nov 18, 2008
Hi and thanks for the feedback! still not getting anything in Firefox (v3), but in safari 3 for windows, if I click on the link (after making the changes that u suggested) to open the modal, then close it, and then click on say my search linkbutton, I get the redirected to following address: http://localhost:1904/sacplan_pub_v2/EmailPage.aspx?__EVENTTARGET=ctl00%24cmdSearch&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTE1OTA1MDAwMzlkZEGnKIEi2UseCpjvA9hREAX2JsOW&txtEmailName=&txtEmailEmail=
Nov 18, 2008
Could you send here the 2 aspx files generated here please.
Nov 18, 2008
ok, I cannot explain this...I've put together a small app, that just takes out the necessary bits from my main app (unfortunately cant post that). Everything regarding the modal and link that supposedly doesn't work - works in this app, but not in my main app! I must stress that I have have done nothing differently, besides working with MasterPages. anyway, I've zipped the solution for u to have a look at.
Nov 18, 2008
Sorry for the missunderstanding. Could you send me the HTML files resulting of the ASP.Net process. As I don't developp with aspx, I can't figure out what will be the final result...
Dec 2, 2008
I don't know if it'll help you, but a nyroModal ASP.Net plugin has just been released. You could download it here : https://code.google.com/p/nyromodal/downloads/detail?name=nyroModal.ASP.net-1.0.zip as I didn't develop it, i can't help on how to use it, but I'll transmit all remarks and suggestion to the developer.
Dec 2, 2008
prishalan; I've taken a look at the files you uploaded in #8 (having first ported to a VS2005 Ajax ASP.NET Web App). I'm not entirely sure as to the problem you are having; after closing any of the nyroModals on the page, I am able to click the LinkButton within the UpdatePanel and the page redirects to Default2, with the contents of TextBox1 in the query variable. All the nyroModals worked as I would expect them too (taking into account that the 'normal' one cannot do a true 'postback' because it is loaded in using AJAX -- instead it redirects to Default2.aspx?i=12345) Incidently, I can't see a similarity between your issue (buttons/linkbuttons not posting back after nyroModal is closed) and the ones you have linked in #3 and #4 (buttons/linkbuttons on a dialog cannot postback to the parent page). The latter (as all of the linked threads have pointed out) is due to how modal dialogs typically append themselves as the last element of the body, whereas ASP.NET postback controls must exist inside the form and should be fixable by any of the methods given (including Cedric's at #5). Realistically, if you are still having postback issues after closing a nyroModal, we will need to be able to examine the HTML output of the page where you are experiencing the error. If it is too sensitive to post online, drop one of us an email with the details. Regards, jimbobmcgee (author of https://code.google.com/p/nyromodal/downloads/detail?name=nyroModal.ASP.net-1.0.zip)
Feb 13, 2009
We are also using NyroModal on an ASP.NET project and we think we've figures out why form controls inside the modal will not post back. Once the modal is opened, it moves the element selected outside of the form! In ASP.NET pages a <form> tag comes right after the <body>, and teh entire page is a form - everything that happens is based on a postback. Is there any way we can get the modal to stay inside this form? It always comes directly after the body tag and has an id="aspnetForm"
Feb 14, 2009
in the last version, you could probably use the blocker settings (set to #aspnetForm in your case) and it should work.
Feb 18, 2009
Hi jimbobmcgee. An excellent job on the ASP.NET version of nyroModal!! Using the normal jQuery plugin, I used to also experience similar problems to prishalan and chris.m.barr. I know that you have provided a neat CHM help file with the binary, but would it also be possible to provide an example of an AJAX method using your plugin? I am using web/page methods and currently calling via Javascript. Having the callback functionality within nyroModal would certainly boost my site's user experience. Please could you provide this solely as an illustration, as I am still learning how to make AJAX calls properly. much thanks krishen
Mar 27, 2009
hi jimbobmcgee! Im so terribly sorry for replying after so long. Thank u for your valuable contribution and for your ASP.NET version of the plugin. As I mentioned in my post#8, I still have no idea why those modals work without affecting any existing elements. I did however omit something...in the application I was initially doing, I had an ASP.NET AJAX UpdatePanel in the page inside the nyromodal popup, with code attached to one of the buttons inside that - that may have caused the problem. I think that this problem went away after changing the type to 'iframe', but I chose not to use that for some reason and just stuck with the default type. As Krishen above mentioned, would it be at all possible to upload a small "hello world" Ajax example with your plugin? I have always wanted to know how when executing an AJAX request, say from a button click event, to 'shrink' the modal to just show the loading gif, and then enlarge itself once the AJAX request is complete, with some new HTML content inside the modal informing the user of the outcome of the completed request. Please could you help me out here? Much thanks! prishalan
Apr 22, 2009
Yes, the blocker setting worked for us. The modal would appear outside of the form,
so adding the following to our code makes it work perfectly.
$('.nyroModal').nyroModal({'blocker':'#aspnetForm'});
May 14, 2009
Any thoughts on this problem guys. http://stackoverflow.com/questions/862259/nested-asp-net-web-forms-nyromodal-postbacks-die-after-modal-is-closed I am essentially having the same problem, but the contents of my modal window is another ASP.Net web form page. So essentially, I'm ending up with nested forms. It's confusing the hell out of both browsers (IE7/FF) and it breaks all postback functionality after the modal closes. I'm stuck with using ASP.Net for work purposes, normally its the last platform I would choose for web development for obvious reasons, but I need to sort this out as I've used nyromodal right throughout this application and for UI consistency I'd like to solve this issue. Thx a lot
Jun 12, 2009
Look at my previous post. Just add $('.nyroModal').nyroModal({'blocker':'#aspnetForm'});
and it opens the modal inside the form
Jan 14, 2010
I had the same problem and $('.nyroModal').nyroModal({'blocker':'#aspnetForm'});
didn't work for me. I've tried couple of ways and nyrodev's code worked the best.
I've used it like this:
var oldForm;
$(function(){
$('.modal').live('click', function(evt){
oldForm = window.theForm;
$(this).nyroModalManual({endFillContent: function(elts, settings) {
window.theForm = $('#aspnetForm', elts.content).get(0);
},
endRemove: function(elts, settings) {
window.theForm = oldForm;
}
});
evt.preventDefault();
});
});
Feb 16, 2011
Hey Everyone, None of the solutions above worked for me... I solved the issue with the placeholder div being placed outside the form tag by changing the following code in jquery.nyroModal.custom.js
nyroModal: function(opts, fullObj) {
if (_internal.firstInit) {
_internal._container = $('<div />').appendTo($b);
to
nyroModal: function(opts, fullObj) {
if (_internal.firstInit) {
_internal._container = $('<div />').appendTo(jQuery('#aspnetForm'));
Around line #522 ...For reference I'm using v2.0.0
I am now able to have ASP.NET Controls in nyroModal dialogs and posting + ViewState work as expected...
Nov 14, 2011
I was encountering the same problem. But thanks to the solution posted in Comment #21, it works for me now :)
Nov 14, 2011
I was encountering the same problem. But thanks to the solution posted in Comment #21, it works for me now :)
Jan 9, 2012
#21 worked for me too thanks very much!
Jul 14, 2012
I have tried to apply comment no 21 in my asp.net 4.0 application but its not working. any help would be greatly appreciated.
Jul 17, 2012
I guess going from the v1 to v2 the "blocker" setting has been moved. I found out that you can use elts settings to define where exactly each element will append to.
The element elts.all will define where the main wrapper for the whole modal will be placed. Since I have a specific location where I want my modal to appear on top of I have an element with the id of "#block". But when you define the elts.all, it will only work on the first load. Because during the close event of the modal, it will call elts.all.remove(). Since this was the case, I decide to use the initElts filter to simply append elts.all to an element before it starts loading everything else.
Below is the an example of how I use it.
$('.nyroModalCompose').nyroModal({
callbacks: {
initElts: function (nm) {
$("#block").append(nm.elts.all);
},
},
});
With that setting, anytime the modal appears it will be appendto "block". You can use the same concept to attach to "#Form" or "#aspnetForm" depending on how you name your form in your aspx file.
I copied and pasted from nyroModal.nyrodev.com for reference:
elts: { // HTML elements for the modal
all: undefined,
bg: undefined,
load: undefined,
cont: undefined,
hidden: undefined
},
|