質問

ASP.NETページのLightBox内に送信フォームを表示する必要があります。 ユーザー名が一意ではないなどの送信フォームにエラーがある場合は、ポストバックはLightBoxの外側にASP.NETページをレンダリングします。 どうやってその問題を解決することができますか?

LightBoxを含む.aspxページのコードスニペット:

<...>
<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は、フォームフィールド、フィールドバリデータ、表示、エラー(例えば、ユーザー名が一意ではない)と送信ボタンを含む単なる.aspxページです。 POSTBACKがcontactform.aspxで発生すると(もちろん)それはライトボックスの外部にレンダリングされます。LightBox内のContactForm.aspxのポストバックを表示できますか? あなたの助けをありがとう!

役に立ちましたか?

解決

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