Pregunta

Necesito mostrar un formulario de envío dentro de una caja de luz de una página ASP.NET. Si hay un error en el formulario de envío, como el nombre de usuario, no es único, la devolución del PostSume realiza la página ASP.NET fuera de la caja de luz. ¿Cómo puedo resolver ese problema?

Aquí hay un fragmento de código de la página .aspx que incluye la caja de luz:

<...>
<p>
    QunatumMotors is located in Detroit. Please use the link below to contact us.</p>
<p>
 <!--START CONTACT FORM OVERLAY-->

        <!-- first overlay. id attribute matches the selector -->
        <a href="**../informational/contactform.aspx"** rel="#overlay" style="text-decoration:none">
        &gt; Click here to contact us
        </a>

        <div class="simple_overlay" id="form_contact">
            <!-- overlayed element -->
            <div class="apple_overlay" id="overlay">
                <!-- the external content is loaded inside this tag -->
                <div class="contentWrap"></div>
            </div>
        </div>
 <!--END CONTACT FORM OVERLAY-->

<p>&nbsp;</p><p>&nbsp;</p>
<...>

ContactForm.aspx es solo una página .ASPX estándar con campos de formulario, validadores de campo, etiqueta para mostrar errores (por ejemplo, nombre de usuario no único) y botón. Cuando se produce un pase de devolución en ContactForm.ASPX, (por supuesto) se presenta fuera de la caja de luz.¿Cómo puedo mostrar la devolución de datos de contactform.aspx dentro de la caja de luz? Gracias por tu ayuda!

¿Fue útil?

Solución

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.)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top