Hi all.

As I'm a newbie and learning VB.NET, I have some questions about pages within pages or maybe even another facit of coding. First, is there a way to call and load an aspx page within another aspx page? Secondly, would this be better accomplished using modules?

Here's a small overview of what I'm trying to do...

In a Request Forms web app, there are systems which have their own request form. From the default page, the user is asked which "system form" they will need. Upon selecting a radio button, the form (each form has different questions) will dynamically display below which the data from the form will be submitted to a SQL db.

Any suggestions? Please include examples if possible.

Thank you.

First, to include pages inside other pages, use the code below:

<!-- Include Virtual="/filename.ascx" -->

You should always use the ascx extension for include files in asp.net They are unable to be displayed in browser and prevents hacking. It works the same as an aspx file but with an unviewable file when manually typing it's address.

Two ways you can do your radio list. One way is through javascript, the other is through the server. Through javascript, you would use the visibility action and it would be instant on the page without reloading. Downfall of this is that some people do not have javascript enabled, and that the person has to download ALL information on the page, whether or not it is relavent to them.
The other way is through the server. You would place all forms in one runat=server form tag with all elements placed in placeholders with the visibility off except for your radiolist. When a user clicks on the radiolist (and you should have autopostback="true" within your radiolist, it will post back to the server and your coding will do a simple select case or if statement to see which is true. Following which is true, the placeholder
s visibility would be set to true and the next step on the form would be available.

<script  runat="server">
Sub btnSubmit_OnClick(sender As Object, e As EventArgs)
  if radiolist1.SelectedItem.Text = 1 then
    rblChooseForm.Visible = False
   	phForm1.Visible = True
  elseif radiolist1.SelectedItem.Text = 2 then
    rblChooseForm.Visible = False
   	phForm2.Visible = True
  elseif radiolist1.SelectedItem.Text = 3 then
    rblChooseForm.Visible = False
   	phForm3.Visible = True
  else
    rblChooseForm.Visible = True
  end if
End Sub
</script>

<form runat="server">
<asp:RadioButtonList OnSelectedIndexChanged="btnSubmit_OnClick" autopostback="true" id="rblChooseForm" runat="server">
  <asp:ListItem Text="Form 1" value="1" />
  <asp:ListItem Text="Form 2" value="2" />
  <asp:ListItem Text="Form 3" value="3" />
</asp:RadioButtonList>
<asp:PlaceHolder Visible="false" id="phForm1" runat="server">
  <table>
    <tr>
      <td>Form 1 here</td>
    </tr>
  </table>
</asp:PlaceHolder>
<asp:PlaceHolder Visible="false" id="phForm2" runat="server">
  <table>
    <tr>
      <td>Form 2 here</td>
    </tr>
  </table>
</asp:PlaceHolder>
<asp:PlaceHolder Visible="false" id="phForm3" runat="server">
  <table>
    <tr>
      <td>Form 3 here</td>
    </tr>
  </table>
</asp:PlaceHolder>
</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.