Frage

Ich muss ein Einreichungsformular in einer Lightbox auf einer ASP.NET-Seite anzeigen. Wenn im Einreichungsformular ein Fehler auftritt, z. B. Benutzername, nicht eindeutig, ist das Postback die ASP.NET-Seite außerhalb der Leuchtkasten. Wie kann ich dieses Problem lösen?

Hier ist ein Code-Snippet der .aspx-Seite, der die Leuchtkasten enthält: generasacodicetagpre.

contactform.aspx ist nur ein Standard .aspx-Seite mit Formularfeldern, Feldprüfer, Etikett, um Fehler anzuzeigen (z. B. Benutzername nicht eindeutig) und senden Sie die Schaltfläche. Wenn ein Postback auf ContactForm.aspx auftritt, wird es dann (natürlich) außerhalb der Leuchtkasten gerendert.Wie kann ich den Postback von contactform.aspx in der lightbox anzeigen? Vielen Dank für Ihre Hilfe!

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top