views:

1025

answers:

4

Hi All,

I have an ASP.Net web page, which uses a Master Page template.

The page has an UpdatePanel with some basic AJAX functionality (change the value of a DropDownList and the UpdatePanel will refresh). This is all working nicely.

I also have a link that pops up a nyromodal Modal, inside the modal, another ASP.Net web form is loaded.. Because I want this page itself to have its own functionality and not just be a static page etc. Its a "Create New" dialogue to be precise. So it creates a new record, then when it closes you go back to the main "list of records" page etc.

I'm using the following jQuery code to initiate the nyromodal calls. This code also includes various other tweaks and settings to make nyromodal more compatible with ASP.Net, as this is about the 5th successive incompatibility I've faced and solved between nyromodal and ASP.Net (Lesson: Stay away from ASP.Net)

$(document).ready(function(){
    $(function(){
      $('.modal').live('click', function(evt){
        $(this).nyroModalManual({'blocker':'#aspnetForm',minWidth:640,minHeight:400,endShowContent:function(elt, settings) { $('input:text:first', elt.content).focus(); }});
        evt.preventDefault();
      });
    });
});

This code is working very well (Thanks Brian) as it solves a couple of other problems with ASP.Net and nyromodal working together. Its even using the blocker:#aspnetForm bit which stops nyromodal from going outside of ASP.Net's main postback form named aspnetForm, which is meant to solve an almost identical problem.

BUT..

The web page that I'm loading into my modal, is ALSO a .Net web form. So it also has its own built-in postback aspnetForm of course. So when the modal appears and I use FireBug to check the DOM structure, I actually have two ASP.Net forms now (nested). And because nyromodal is essentially just a div (or a few divs), the form tags are essentially nested.

So I think this is screwing things up big time. It's actually crashing IE7 totally (fatal exceptions). IE7 + FireFox: When I close the dialogue, my main web form won't postback any more. I think its been very confused by the 2 form tags that were there a moment ago.

It should be a really simple requirement to be able to open an ASP.Net web form as the contents of your modal using nyromodal. I do blame it on ASP.Net for being so lame and putting a mandatory "form" tag in every page. If I was using PHP, I wouldn't have experienced ANY of these problems I've had today, but I'm stuck using ASP.Bloat for work purposes.

Any thoughts or insight greatly appreciated! :)

A: 

Hi Aaron, Im actually the person who reported that issue. Firstly, have u tried the ASP.NET nyroModal plugin that jimbobmcgee (on the same page u linked to) developed? I haven't as yet, as I coludnt find the time to go thru the contained documentation. If u do tho, let me know how i works out for u.

This is actually perfect timing...Another alternative, which is what Im in the midst of investigating, is using normal HTML pages instead of WebForms in the modal. So, I intend to wrap my server-side code within a webservice, and use jQuery to make a call to it, and return a JSON response.

Forgive the accuracy of my explanation, as I just started with webservices and page methods, so I am too learning. Hence the reason my asking for someone to post a simple "Hello World" example.

Hope that helps a bit.

Shalan
Thanks Shalan. Yeah not bad thinking actually. I've used .Net web service methods once so far, it seemed to work fine, but the only problem of course is that everything has to be static, so you lose the state of your page and so forth. But for a typical modal, hopefully it should be fine.Thanks for getting in touch and the suggestions. I haven't used the .Net plugin yet either. I might give it a go..Do you use ASP.Net MVC at all?Cheers
Aaron
Yea, pitty about that.Do u follow Dave WArd's blog - Encosia? He covers these topics very well. No havent started using MVC yet...although I see the benefits. Need to understand the MVC pattern before blindly going into it! :)My 2 modal applications are to display information (from database for example) and capture data thru html form. utilising jQuery Validation for this. Haven't begun tying in the webservices as yet tho. Let me know how things work out for u. Maybe we can help each other out. Cheers!
Shalan
Will do Shalan, cheers. I've seen that blog and searched on a few things that have been helpful. But generally I don't use ASP.Net by choice, only because of work. I've used many other web platforms and I find it the most frustrating unfortunately. Most of the other platforms are so much more direct and you can just get in under the hood and do exactly what you need to to any JS/HTML/CSS etc, with .Net there's so much bloat and hassle to do a lot of simple tasks that would take me 2 mins in PHP :( But it pays the bills at the moment.
Aaron
:D yeah, I get into arguments with friends about which is better...PHP/ASP.NET....and there's never a winner! I think it comes down to programmer preference and to a certain degree, the type of application u are creating. Because I also develep for Windows Forms and Windows Mobile, I find it great. BUT - I do see the shortcomings of traditional ASP.NET webforms, and Im really looking forward to learning MVC - no viewstate, page lifecycle or INmaingContainers...exactly as u said: "just get in under the hood and do exactly what you need to". cheers!
Shalan
I just cracked and downloaded ASP.Net MVC :) The learning curve is going to delay my project further, which is already overdue, but hopefully I can catch up and save time from the "benefits" :) Cheers.
Aaron
A: 

If you put this in the head of a page. It allows nyro modal closing to simulate a postback.

<script type="text/javascript">
$(document).ready(function(){$.nyroModalSettings({
  modal: true,minWidth: ###,minHeight: ###,
  endRemove:function(){
   document.location='pageYouWantToRefresh.aspx';
  }    
});});  
</script>

just change document.location and it will go there when the window closes.

ThorDivDev
A: 

Have you considered opening the page in the modal as an iFrame so that its contents (the new form tag, etc.) will not interfere with the host page?

$(this).nyroModalManual({type:'iframe'});
patmortech
A: 

The easiest solution I've found sofar is to load the popup window as an iframe, not inline or via AJAX. Just a thought. :)

ianpoley

related questions