سؤال

أحتاج إلى عرض نموذج التقديم داخل صندوق Lights من صفحة ASP.NET. إذا كان هناك خطأ في نموذج التقديم مثل اسم المستخدم غير فريد من نوعه، فإن عون البريد ثم يجعل صفحة ASP.NET خارج LightBox. كيف يمكنني حل هذه المشكلة؟

هنا هو مقتطف رمز صفحة .aspx التي تتضمن LightBox: giveacodicetagpre.

contactform.aspx هو مجرد صفحة .aspx قياسية مع حقول النماذج، منصقة الحقول، الملصق لعرض الأخطاء (E.G. اسم المستخدم غير فريد) وتقديم زر. عند إجراء عملية إعادة النشر على ContactForm.aspx ثم (بالطبع) يتم تقديمها خارج LightBox.كيف يمكنني عرض عون البريد ContactForm.aspx داخل LightBox؟ شكرا لمساعدتكم!

هل كانت مفيدة؟

المحلول

The lightbox content isn't like another tab or window: it becomes part of the host page.

In other words, it incorporates the HTML generated by contactform.aspx into the host page's document object model (DOM). Activating the lightbox adds a form to the host page that posts to the contact page:

 <html><body>
     <!-- host page content here -->
     <!-- contact form content -->
     <form action="contactform.aspx">
         <!-- text boxes, buttons, etc. -->
     </form>
 </body></html>

When the user submits, their browser issues a new request: a POST to contactform.aspx. That request returns the contact form's HTML.

There are several ways you might work around that:

  • Use ajax to perform the update asynchronously. (You might even be able to do this by using an UpdatePanel in contactform.aspx, but I don't use them much anymore and haven't though that through).

  • Convert contactform.aspx into a control (if you're using it in several places) and embed it in the host page.

  • At the end of the contact form's submit handler, redirect to the host page with a flag that instructs the page to immediately activate the lightbox. (This has numerous issues and sounds pretty fragile ... but it's plausible.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top