0
<asp:PlaceHolder ID="pnlThanks" runat="server" Visible="false">
          <p><asp:Literal  ID="lblReceipt" runat="server"></asp:Literal></p>
</asp:PlaceHolder>   
<asp:PlaceHolder ID="pnlForm" runat="server" Visible="true">
         <form id="form1" runat="server" class="busgroup-form">
          //// All form controls
          </form>
</asp:PlaceHolder>

Code Behind file:

  Protected Sub submit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdsubmit.Click
      form1.Controls.Clear()
      pnlForm.Visible = False
      pnlThanks.Visible = True
  End Sub

So, after submitting form when "pnlThanks" placeholder is visible, I can see proper contents displayed on page. But when I do "view source" on the browser, I see the source code for form and not the content inside "pnlThanks" placeholder.

What am I doing wrong ?

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Ani
  • 4,473
  • 4
  • 26
  • 31

3 Answers3

2

You need to have all of your controls within the <form> tag, because ASP.NET depends upon the form to do postbacks, etc.

You can only have one <form> tag in your page.

Change your code to this:

<form id="form1" runat="server" class="busgroup-form">
    <asp:PlaceHolder ID="pnlThanks" runat="server" Visible="false">
        <p><asp:Literal  ID="lblReceipt" runat="server"></asp:Literal></p>
    </asp:PlaceHolder>
    <asp:PlaceHolder ID="pnlForm" runat="server" Visible="true">
    </asp:PlaceHolder>
</form>
Karl Anderson
  • 34,606
  • 12
  • 65
  • 80
0

Your code works as expected when I tested it. My guess is there is another pnlForm.Visible = True in your code elsewhere that is executed on your postback.

Ceres
  • 3,524
  • 3
  • 18
  • 25
0

pnlThanks isn't rendered if visible=false, therefore it won't show in the source. You can use CSS (display=none) to hide it on start and change when needed.

David Sdot
  • 2,343
  • 1
  • 20
  • 26