嵌套 ASP.Net Web 表单 + nyromodal :模式关闭后回发消失

发布于 2024-07-20 07:12:54 字数 1521 浏览 4 评论 0原文

我有一个 ASP.Net 网页,它使用母版页模板。

该页面有一个带有一些基本 AJAX 功能的 UpdatePanel(更改 DropDownList 的值,UpdatePanel 将刷新)。 这一切都运行良好。

我还有一个弹出 nyromodal 模态的链接,在模态内部,加载了另一个 ASP.Net Web 表单。因为我希望此页面本身具有自己的功能,而不仅仅是静态页面等。它是“创建准确地说,是新的对话。 因此它会创建一条新记录,然后当它关闭时,您将返回主“记录列表”页面等。

我使用以下 jQuery 代码来启动 nyromodal 调用。 代码还包括各种其他调整和设置,以使 nyromodal 与 ASP.Net 更加兼容,因为这是我在 nyromodal 和 ASP.Net 之间遇到并解决的第五次连续不兼容性(课程:远离 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();
      });
    });
});

此 代码运行得很好(感谢 Brian),因为它解决了 ASP.Net 和 nyromodal 协同工作的其他几个问题。 它甚至使用 blocker:#aspnetForm 位来阻止 nyromodal 超出 ASP.Net 名为 aspnetForm 的主回发表单,这旨在解决 几乎相同的问题

但是..

我加载到模式中的网页也是一个.Net Web 表单。 所以它当然也有自己内置的postback aspnetForm。 因此,当模式出现并且我使用 FireBug 检查 DOM 结构时,我实际上现在有两个 ASP.Net 表单(嵌套)。 而且因为 nyromodal 本质上只是一个 div(或几个 div),所以表单标签本质上是嵌套的。

所以我认为这把事情搞砸了。 它实际上使 IE7 完全崩溃(致命异常)。 IE7 + FireFox:当我关闭对话框时,我的主网络表单将不再回发。 我认为刚才的两个表单标签让它非常困惑。

能够使用 nyromodal 打开 ASP.Net Web 表单作为模式的内容应该是一个非常简单的要求。 我确实将其归咎于 ASP.Net 如此蹩脚并在每个页面中放置了强制的“form”标签。 如果我使用 PHP,我就不会遇到今天遇到的任何这些问题,但出于工作目的,我不得不使用 ASP.Bloat。

任何想法或见解都非常感谢! :)

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! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一直在等你来 2024-07-27 07:12:54

您是否考虑过将模式中的页面作为 iFrame 打开,以便其内容(新的表单标签等)不会干扰主机页面?

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

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'});
峩卟喜欢 2024-07-27 07:12:54

我实际上是报告该问题的人。 首先,您是否尝试过 jimbobmcgee 的 ASP.NET nyroModal 插件(在您链接到的同一页面上)开发? 我还没有,因为我没有时间去阅读所包含的文档。 如果你这样做,请告诉我我是如何为你锻炼的。

这实际上是完美的时机...另一种选择,也就是我正在研究的,是在模式中使用普通的 HTML 页面而不是 WebForms。 因此,我打算将服务器端代码包装在 Web 服务中,并使用 jQuery 调用它,并返回 JSON 响应。

请原谅我解释的准确性,因为我刚刚开始接触网络服务和页面方法,所以我太学习了。 因此,我要求某人发布一个简单的“Hello World”示例。

希望有点帮助。

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.

恏ㄋ傷疤忘ㄋ疼 2024-07-27 07:12:54

如果你把它放在页面的头部。 它允许 nyro 模态关闭来模拟回发。

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

只需更改 document.location,当窗口关闭时它就会转到那里。

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.

又爬满兰若 2024-07-27 07:12:54

到目前为止,我发现的最简单的解决方案是将弹出窗口加载为 iframe,而不是内联或通过 AJAX。 只是一个想法。 :)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文